Skip to content

rakibulmuhajir/laravel6-crud-brief-intro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 

Repository files navigation

laravel6-crud-brief-tutorial

Laravel 6 CRUD Brief Tutorial

  1. Create a database named "shows"
  2. create a model by following command php artisan make:model show-m
  3. Previous command will create show.php and [timestamp]create_shows_table.php migration file. go to migration file and add table schema in up method like this
    public function up()
    {
        Schema::create('shows', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('show_name');
            $table->string('genre');
            $table->float('imdb_rating');
            $table->string('lead_actor');
            $table->timestamps();
        });
    }
    
    </code>
    
  4. Run migration command to add tables to the database php artisan migrate
  5. Inside app/show.php we add fillable properties. These are the properties which can be mass assigned.
      <?php
    
    namespace App;
    
    use Illuminate\Database\Eloquent\Model;
    
    class Show extends Model
    {
    protected $fillable = ['show_name', 'genre', 'imdb_rating', 'lead_actor'];
    }
    
  6. Now we create a show controller with --resource flag. which will add CRUD methods automatically
    php artisan make:controller ShowController --resource
    Then we go to routes/web.php and add following
     <?php
        // ShowController.php
    
    Route::get('/', function () {
    return view('welcome');
    });
    
    Route::resource('shows', 'ShowController');
    

About

Laravel 6 CRUD Brief Walkthrough

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published