8 public function preferredLocale(): string 9 { 10 return $this->locale; 11 } 12}Once you have implemented the interface, Laravel will automatically use the preferred locale when sending mailables and notifications to the model. Therefore, there is no need to call the locale method when using...
1class UserController extends Controller 2{ 3 /** 4 * Instantiate a new controller instance. 5 * 6 * @return void 7 */ 8 public function __construct() 9 { 10 $this->middleware('auth'); 11 $this->middleware('log')->only('index'); 12 $this->middleware('subscribed')->except('...
FFMpeg::open('steve_howe.mp4') ->exportForHLS() ->withRotatingEncryptionKey(function ($filename, $contents) { $videoId = 1; // use this callback to store the encryption keys Storage::disk('secrets')->put($videoId . '/' . $filename, $contents); // or... DB::table('hls_...
// app/Processes/TestProcess.php public static function callback(Server $swoole, Process $process) { while ($data = $process->read()) { \Log::info('TestProcess: read data', [$data]); $process->write('TestProcess: ' . $data); } } // app/Http/Controllers/TestController.php public...
First, add a new call to RateLimiter::for() inside the boot method of your RouteServiceProvider, where you pass a fitting rate limiter name:<?php RateLimiter::for('process-data', function (Request $request) { Limit::perDay(2)->by($request->user()->id); });...
<?php namespace App\Http\Controllers\API; use App\Http\Controllers\Controller; use App\User; use Illuminate\Http\Request; class AuthController extends Controller { public function register(Request $request) { $validatedData = $request->validate([ 'name' => 'required|max:55', 'email' => '...
//rotte API Route::group(['namespace'=>'Auth','prefix'=>'api'],function() { Route::post('/my_sr_ldap_verify','LoginController@my_sr_ldap_verify'); Route::post('/my_ldap_verify','LoginController@my_ldap_verify'); Route::post('/mysql_verify','LoginController@mysql_verify'); Rou...
public function exportUserList(UserListExport $export) { // work on the export return $export->sheet('sheetName', function($sheet) { })->export('xls'); } } Export Handlers 导出事件处理器 To decouple your Excel-export code completely from the controller, you can use the export handlers....
Feel the need to call controllers from other controllers? This is often indicative of poor application design and too much business logic in your controllers. Extract the logic into a third class that can be injected into any controller.
<?phpnamespaceApp\Http\Controllers;useApp\Task;useApp\Link;classGanttControllerextendsController{publicfunctionget(){$tasks=newTask();$links=newLink();returnresponse()->json(["data"=>$tasks->all(),"links"=>$links->all()]);}} And register a route, so the client could call this action...