PHP code example of saritasa / laravel-controllers
1. Go to this page and download the library: Download saritasa/laravel-controllers 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/ */
saritasa / laravel-controllers example snippets
class UserApiController extends BaseApiController
{
public function __construct(UserTransformer $userTransformer)
{
parent::__construct($userTransformer);
}
public function editUserProfile(Request $request, User $user): Response
{
$this->validate($request, $user->getRuels());
$user->fill($request->all());
$user->save();
return $this->json($user);
}
}
namespace App\Providers;
use App\Http\Requests\Auth\LoginRequest;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
use Saritasa\LaravelControllers\Requests\Concerns\ILoginRequest;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
$this->app->bind(ILoginRequest::class, LoginRequest::class);
}
}
namespace App\Http\Requests\Auth;
use Illuminate\Foundation\Http\FormRequest;
use Saritasa\LaravelControllers\Requests\Concerns\ILoginRequest;
class LoginRequest extends FormRequest implements ILoginRequest
{
/**
* @inheritDoc
*/
public function rules(): array
{
return [
'username' => '