PHP code example of nabil12ful / store-data-requests

1. Go to this page and download the library: Download nabil12ful/store-data-requests library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nabil12ful / store-data-requests example snippets


composer 

php artisan vendor:publish --provider="Nabil\StoreDataRequestsServiceProvider"

php artisan make:controller UserController -r

php artisan make:controller UserController -m User

protected $model = \App\Models\User::class;

protected $folderBlade = 'backend.user'; // View folder name OR path

protected $uploadPath = 'upload/user';

protected $columns = [
	// table columns & fields name
	'name',
	'email',
];

protected $mediaColumns = [
    // columns name have a media files like [Image, Pdf, Doc, etc...]
    'image'
];

php artisan make:request UserStoreRequest

public function store(UserStoreRequest $request): RedirectResponse
{
	StoreDataRequests::model($this->model)->make($request, $this->columns)->store($this->uploadPath);
}

protected $columns = [
	// table columns & fields name with rules
	'name' => 'ns & fields name has files with rules
	'image' => '

public function store(Request $request)
{
	$result = StoreDataRequests::model($this->model)->make($request, $this->columns)->storeValidated('upload/users');

    if(isset($result->id))
    {
        toastr()->success('The data has been stored successfully', 'Success');
        return redirect()->back();
    }else{
        return back()->withInput()->withErrors($result);
    }
}

public function update($id, Request $request)
{
	$result = StoreDataRequests::model($this->model)->make($request, $this->columns, $this->mediaColumns)->updateHasFilesValidate($id, $this->uploadPath);

    if(!$result)
    {
        toastr()->success('The data has been updated successfully', 'Success');
        return redirect()->back();
    }else{
        return back()->withInput()->withErrors($result);
    }
}

StoreDataRequests::model($this->model)->delete(decrypt($id), $this->uploadPath);

use Nabil\StoreDataRequests;

public function store(Request $request)
{
	StoreDataRequests::model('Prodect')->make($request, ['title','description'])->store();
}

public function update(Request $request, $id)
{
	StoreDataRequests::model('Prodect')->make($request, ['title','description'])->update($id);
}

StoreDataRequests::model('Prodect')->make($request, ['title','description'], ['image'])->store('path/to/upload');

StoreDataRequests::model('Prodect')->make($request, ['title','description'], ['image'])->update($id, 'path/to/upload');