Laravel API Artisan Command

resources:create Creates all the files you need to create an API resource

php artisan resources:create PostChecking  if  the  model  exists ... The  model  Post does  not  exist. Should I create it? (yes/no)[yes]: > Should I create the migration  for  Post? (yes/no)[yes]: > Should I create the factory  for  Post? (yes/no) [yes]: > Should I create the seeder  for  Post? (yes/no)[yes]: >Creating  6 resources ...

The command creates the following files for you:

  • Controller
  • Form request
  • Resource and resource collection
  • Policy
  • model
  • Database factory
  • Database migration
  • Database seeder
  • Routes

routes/api.php File added routes :

/*|--------------------------------------------------------------------------| Post endpoints|-------------------------------------------------------------------------- */Route::name('posts.')->prefix('posts')->group(function () { Route::get('/', '[email protected]')->name('index'); Route::post('/', '[email protected]')->name('create'); Route::get('/{post}', '[email protected]')->name('show'); Route::patch('/{post}', '[email protected]')->name('update'); Route::delete('/{post}', '[email protected]')->name('destroy');});

Click here to learn more about this package


KARABAY A, 2020 . Laravel API Artisan Command,

(Accessed February 16, 2020).

  Share this post

Comments (0)


Sign up for the email newsletter to be the first to know about my blog posts