Laravel has its own command-line interface named Artisan. It has a list of useful commands. You’ll need to use artisan commands when building an application.
You may get into situations when you’ll have no access to SSH. In such situations, you might want to execute artisan commands programmatically from a router or controller.
Laravel provides a facade class for the Artisan, which has a call()
method that we can use to execute artisan commands, the signature name or class name of the command as the first argument, and the second argument is an array of command parameters. Alternatively, we can just pass the complete artisan command as a string. For example – We gonna run posts table seeder using artisan command programmatically this way –
Route::get('artisan-seed', function() {
Artisan::call(
'db:seed ',
array(
'--class' => 'PostTableSeeder'
)
);
// Alternatively
Artisan::call('db:seed --class=PostTableSeeder');
});
Today I will share a snippet I've used in a project. Using that function, you…
JavaScript AJAX (Asynchronous JavaScript and XML) is a technique that gives the ability to send…
By default, Bootstrap carousel has no way to add animations to carousel elements. Here I'm…
Laravel comes up with a paginator that generates HTML compatible with the Tailwind CSS framework.…
Bootstrap introduced their icons collection in November 2019 as Bootstrap Icons (v1.0.0-alpha). At that time,…
To create autocomplete feature for input field(s), HTML's datalist tag can be the easiest solution.…