You can use Laravel scopes to DRY up the code. The scope is just a method that you can use in your model to encapsulate the syntax used to execute a query such as above. Scopes are defined by prefixing the name of a method with scope, as below. Scope class will be implemented from... Continue Reading →
Laravel Sail – Setup
Install Sail by use your existing local development environment allows you to install Composer dependencies. https://laravel.com/docs/8.x/sail Install Sail : https://laravel.com/docs/8.x/sailcomposer require laravel/sail --devphp artisan sail:install./vendor/bin/sail up (-d : To start all of the Docker containers in the background )sail stop Setup PHPStorm - PHPUnit with docker https://blog.jetbrains.com/phpstorm/2016/11/docker-remote-interpreters/
Laravel – Service / Manager & Interface
Lâu nay web mình toàn post porn không 😀 Nên giờ tự tay viết 1 bài technical chút. Về nguyên tắc / lý thuyết sách vở thì nó được gọi là ... gì gì đó pattern ! Nhưng thôi dẹp mẹ nó sách vở qua 1 bên. Câu chuyện là ta xem nó giải quyết... Continue Reading →
Understand Laravel job traits
class ProcessPodcast implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; /** * The podcast instance. * * @var \App\Models\Podcast */ protected $podcast; /** * Create a new job instance. * * @param App\Models\Podcast $podcast * @return void */ public function __construct(Podcast $podcast) { $this->podcast = $podcast; } /** * Execute the job. * * @param... Continue Reading →
XCrawler – Automatically post to WordPress
Okay bài toán này trước đây mình đã xử lý. Tuy nhiên giờ thì xử lý triệt để hơn. Gửi notifications / email khi có favorited movies. Dựa trên genres / castsGửi email khi có movie mới lên WordPress Về cơ bản 2 bài toán này similar nhau. Observe table movies khi có createdKiểm tra... Continue Reading →
Laravel – Horizon & Totem
Lâu rồi không update bài gì cho SoulEvil nên nhân tiện post linh tinh 1 chút về 2 món này. Horizon Okay define 1 chút về Horizon. Giả sử có file conf Supervisor sau [program:laravel-worker] process_name=%(program_name)s_%(process_num)02d command=php /path/to/your/laravel/install/artisan queue:work --sleep=3 --tries=3 autostart=true autorestart=true user=your_local_user numprocs=8 redirect_stderr=true stdout_logfile=/path/to/your/laravel/install/queue.log stderr_logfile=/path/to/your/laravel/install/queue.err.log Oki em Supervisor này có nhiệm xử... Continue Reading →
How to use Google Drive in Laravel
Install package Google Drive API V3 composer require nao-pon/flysystem-google-drive:~1.1 Thêm provider GoogleDriveServiceProvider vào file config/app.php 'providers' => [ // ... App\Providers\GoogleDriveServiceProvider::class, // ... ], Nội dung provider tham khảo ở dưới https://github.com/ivanvermeyen/laravel-google-drive-demo/blob/master/app/Providers/GoogleDriveServiceProvider.php Update tiếp config/filesystems.php 'disks' => [ // ... 'google' => [ 'driver' => 'google', 'clientId' => env('GOOGLE_DRIVE_CLIENT_ID'), 'clientSecret' => env('GOOGLE_DRIVE_CLIENT_SECRET'), 'refreshToken' => env('GOOGLE_DRIVE_REFRESH_TOKEN'),... Continue Reading →
Laravel queue vs XGallery pool
Tất nhiên là win thuộc về Laravel rồi. Tuy nhiên bài này mình đưa ra 1 cách nhìn khác, khi mà mình chưa biết về Laravel.
Use OAuth in Laravel with GuzzleHttp & Socialite
Cái này mất của mình gần như 1 buổi để tìm ra 1 số troubles và hướng giải quyết. Thứ nhất phải làm rõ là Socialite về bản chất nó đóng vai trò như Authenticate ! Và chỉ là Authenticate. Nó không phải là OAuth client thuần tuý ! Do đó không thể dùng nó... Continue Reading →