What are the requirements for Laravel 5.8?
PHP Version>=7.1.3 OpenSSL PHP Extension PDO PHP Extension Mbstring PHP Extension Tokenizer PHP Extension XML PHP Extension Ctype PHP Extension JSON PHP Extension
PHP Version>=7.1.3 OpenSSL PHP Extension PDO PHP Extension Mbstring PHP Extension Tokenizer PHP Extension XML PHP Extension Ctype PHP Extension JSON PHP Extension
In Laravel, a Closure is an anonymous method which can be used as a callback function. It can also be used as a parameter in a function. It is possible to pass parameters into a Closure. It can be done by changing the Closure function call in the handle() method to provide parameters to it. …
The guarded attribute is the opposite of fillable attributes. In Laravel, fillable attributes are used to specify those fields which are to be mass assigned. Guarded attributes are used to specify those fields which are not mass assignable. Code Source class User extends Model { protected $guarded = [‘role’]; // All fields inside the $guarded …
How will you explain Guarded Attribute in a Laravel model? Read More »
In eloquent ORM, $fillable attribute is an array containing all those fields of table which can be filled using mass-assignment. Mass assignment refers to sending an array to the model to directly create a new record in Database. Code Source class User extends Model { protected $fillable = [‘name’, ’email’, ‘mobile’]; // All fields inside …
How will you describe Fillable Attribute in a Laravel model? Read More »
User() function is used to get the logged-in user Example if(Auth::check()){ $loggedIn_user=Auth::User(); dd($loggedIn_user); }
We need to create a new model instance if we want to create a new record in the database using Laravel eloquent. Then we are required to set attributes on the model and call the save() method. Example public functionsaveProduct(Request $request ) $product = new product; $product->name = $request->name; $product->description = $request->name; $product->save();
When an application is in maintenance mode, a custom view is displayed for all requests into the application. It makes it easy to “disable” application while it is updating or performing maintenance. A maintenance mode check is added in the default middleware stack for our application. When an application is in maintenance mode, a MaintenanceModeException …
Laravel is configured to use MySQL by default. To change its default database type, edit the file config/database.php: Search for ‘default’ =>env(‘DB_CONNECTION’, ‘mysql’) Change it to whatever required like ‘default’ =>env(‘DB_CONNECTION’, ‘sqlite’) By using it, MySQL changes to SQLite.
PHP Traits is a group of methods which can be included within another class. A Trait cannot be instantiated by itself like an abstract class. Traits are generated to reduce the limitations of single inheritance in PHP. It allows a developer to reuse sets of methods freely in various independent classes living in different class …
We can implement a package in Laravel by: Creating a package folder and name it. Creating Composer.json file for the package. Loading package through main composer.json and PSR-4. Creating a Service Provider. Creating a Controller for the package. Creating a Routes.php file.