Skip to content

zulfikar-ditya/laravel-api-controller-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Api Controller Helper

This is my controller api helper for laravel app

Usage

  • Move file ControllerHelpers.php to App\Traits
  • then add ControllerHelpers trait in \App\Http\Controllers\Controller
...
 use App\Traits\ControllerHelpers;
...

...
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
    use ControllerHelpers;
...

Simple use:

$users = \App\Models\User::all();

return $this->reponseJsonData($users);

Upload File Helper

some time we need to do some driven design like using service and repository. You can simpify to use the UploadFile.php instead the entire controller helpers

use \App\Traits\UploadFile;

...

$this->uploadFile($request->file('file-name'), 'file-folder');

...
$this->deleteFile($model->file_name ?? '');
$this->uploadFile($request->file('file-name'), 'file-folder');
...

About

This is my controller api helper for laravel app

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages