PHP code example of cuongnd88 / lara-repository

1. Go to this page and download the library: Download cuongnd88/lara-repository 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/ */

    

cuongnd88 / lara-repository example snippets


$ composer 


// config/app.php
return [
    // ...
    'providers' => [
        // ...
        Cuongnd88\LaraRepo\LaraRepoServiceProvider::class,
    ]
    // ...
];

php artisan make:repository --interface=User/UserInterface --repository=User/UserRepository --model=Models/User --controller=User/UserController


php artisan make:repository --interface=Staff/StaffInterface --repository=Staff/StaffRepository --model=Models/Staff --controller=Staff/StaffController@resource




namespace App\Http\Controllers\Staff;

use App\Http\Controllers\Controller;
use App\Repositories\Staff\StaffInterface;
use Illuminate\Http\Request;

class StaffController extends Controller
{
    protected $staffInterface;

    public function __construct(StaffInterface $staffInterface)
    {
        $this->staffInterface = $staffInterface;        
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}



//config/repositories.php
return [
    \App\Repositories\User\UserInterface::class => \App\Repositories\User\UserRepository::class,
    \App\Repositories\Staff\StaffInterface::class => \App\Repositories\Staff\StaffRepository::class,
    \App\Repositories\Language\LanguageInterface::class => \App\Repositories\Language\LanguageRepository::class,

];