briza / manager
with the help of this package we don't have to worry about to the code for CRUD operations
README
CRUD package is an package that makes your crud operations easy and hassle free.
- Easy to integrate with your existing project.
- use alias or provider to import the package.
Installing CRUD Package
The recommended way to install CRUD Package is through Composer.
composer require briza/manager
Steps
Import in config/app.php under providers
'providers' => [ briza\manager\ManagerServiceProvider::class ];
after importing provider you are ready to go.
run migration command to create images table in your DB to upload images
php artisan migrate
in images table you have id of the record whose image you want to upload with table name to map the record with accurate table.
after running migration command run below command to create storage link in public directory.
php artisan storage:link
Example
After importing you can import the provider in your controller.
use briza\manager\Http\Controllers\CrudService
Create the object
public function __construct(CrudService $crud){ $this->crud = $crud; }
in CRUD Package you have basic CRUD functions available to use for instance, to store data:-
Store
/** * @param mixed $request(from user with data),$table(in which table you want to store data) * ,$imageFolder(optional if image is available, where you want to uplaod it) * ,$imageField(image field in the request, in which file is available) * ,$prefix(optional if you want to add a prefix to the image name) * @return mixed array will be returned with status, type, last inserted id, and message. */ $this->crud->store($request,$table,$imageFolder,$imageField,$prefix);
Update
/** * @param mixed $request(from user with data),$id(which record you want to update) * ,$table(in which table you want to update data) * ,$imageFolder(optional if image is available, where you want to uplaod it) * ,$imageField(image field in the request, in which file is available) * ,$prefix(optional if you want to add a prefix to the image name) * @return mixed array will be returned with status, type, id, and message. */ $this->crud->update($request,$id,$table,$imageFolder,$imageField,$prefix);
Delete
with Delete images will also get deleted from storage if available.
/** * @param mixed $id(which record you want to delete),$table(from which table you want to delete data) * @return mixed array will be returned with status, type, id, and message. */ $this->crud->delete($id,$table);
DeleteImage
if you wish to delete an image.
/** * @param mixed $id(which image you want to delete), id is from images table * @return mixed array will be returned with status, type, id, and message. */ $this->crud->deleteImage($id);