Book Image

Laravel Application Development Cookbook

By : Terry Matula
Book Image

Laravel Application Development Cookbook

By: Terry Matula

Overview of this book

When creating a web application, there are many PHP frameworks from which to choose. Some are very easy to set up, and some have a much steeper learning curve. Laravel offers both paths. You can do a quick installation and have your app up-and-running in no time, or you can use Laravel's extensibility to create an advanced and fully-featured app.Laravel Application Development Cookbook provides you with working code examples for many of the common problems that web developers face. In the process, it will also allow both new and existing Laravel users to expand their knowledge of the framework.This book will walk you through all aspects of Laravel development. It begins with basic set up and installation procedures, and continues through more advanced use cases. You will also learn about all the helpful features that Laravel provides to make your development quick and easy. For more advanced needs, you will also see how to utilize Laravel's authentication features and how to create a RESTful API.In the Laravel Application Development Cookbook, you will learn everything you need to know about a great PHP framework, with working code that will get you up-and-running in no time.
Table of Contents (18 chapters)
Laravel Application Development Cookbook
About the Author
About the Reviewers

Using attributes to change table column names

Sometimes we may be working with a database that was created using less-than-logical column names. In those cases, we can use Laravel's Eloquent ORM to allows us to interact with the table using more standardized names, without having to make database changes.

Getting ready

For this recipe, we need a standard Laravel installation, a properly configured MySQL database, and our migrations table set up by running the command php artisan migrate:install.

How to do it...

To complete this recipe, follow these steps:

  1. Create a migration for our table with the column name odd, in the command prompt:

    php artisan migrate:make create_odd_table --table=odd --create
  2. Create a migration to add some data to the table, in the command prompt:

    php artisan migrate:make add_data_to_odd_table
  3. In the app/database/migrations folder, open the create_odd_table migration and add the schema:

    use Illuminate\Database\Schema\Blueprint;
    use Illuminate\Database\Migrations\Migration...