What is the meaning of Eloquent’s Model::query()?

Any time you’re querying a Model in Eloquent, you’re using the Eloquent Query Builder. Eloquent models pass calls to the query builder using magic methods (__call, __callStatic). Model::query() returns an instance of this query builder. Therefore, since where() and other query calls are passed to the query builder: Model::where()->get(); Is the same as: Model::query()->where()->get(); Where … Read more

Laravel 5.6 – Pass additional parameters to API Resource?

The following approach worked for me: UserResource class UserResource extends Resource{ protected $foo; public function foo($value){ $this->foo = $value; return $this; } public function toArray($request){ return [ ‘id’ => $this->id, ‘name’ => $this->name, ‘foo’ => $this->foo, ]; } public static function collection($resource){ return new UserResourceCollection($resource); } } UserCollection class UserResourceCollection extends ResourceCollection{ protected $foo; public … Read more

Laravel mysql migrate error

I finally found the solutions a days ago and I remembered this post. In the config/database.php file in mysql tag, the sql modes should be added in order to skip this error. https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html#sql-mode-full My MySQL array ended up like this: ‘mysql’ => [ ‘driver’ => ‘mysql’, ‘host’ => env(‘DB_HOST’, ‘127.0.0.1’), ‘port’ => env(‘DB_PORT’, ‘3306’), ‘database’ … Read more

tech