1599667020
How To Create Comment Nesting In Laravel From Scratch is the today’s main topic. In any topic specific forum, there is always a structure, where you need to reply to someone’s comment and then somebody reply in their comment and so on. So comment nesting is very useful in any web application, which exposes public interest. In this tutorial, we will do it from scratch. We use Polymorphic relationship in this example.
As always, install Laravel using the following command. I am using Laravel Valet.
#laravel #laravel valet
1595201363
First thing, we will need a table and i am creating products table for this example. So run the following query to create table.
CREATE TABLE `products` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
Next, we will need to insert some dummy records in this table that will be deleted.
INSERT INTO `products` (`name`, `description`) VALUES
('Test product 1', 'Product description example1'),
('Test product 2', 'Product description example2'),
('Test product 3', 'Product description example3'),
('Test product 4', 'Product description example4'),
('Test product 5', 'Product description example5');
Now we are redy to create a model corresponding to this products table. Here we will create Product model. So let’s create a model file Product.php file under app directory and put the code below.
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Product extends Model
{
protected $fillable = [
'name','description'
];
}
Now, in this second step we will create some routes to handle the request for this example. So opeen routes/web.php file and copy the routes as given below.
routes/web.php
Route::get('product', 'ProductController@index');
Route::delete('product/{id}', ['as'=>'product.destroy','uses'=>'ProductController@destroy']);
Route::delete('delete-multiple-product', ['as'=>'product.multiple-delete','uses'=>'ProductController@deleteMultiple']);
#laravel #delete multiple rows in laravel using ajax #laravel ajax delete #laravel ajax multiple checkbox delete #laravel delete multiple rows #laravel delete records using ajax #laravel multiple checkbox delete rows #laravel multiple delete
1623389100
Today, We will see laravel 8 create custom helper function example, as we all know laravel provides many ready mate function in their framework, but many times we need to require our own customized function to use in our project that time we need to create custom helper function, So, here i am show you custom helper function example in laravel 8.
#laravel 8 create custom helper function example #laravel #custom helper function #how to create custom helper in laravel 8 #laravel helper functions #custom helper functions in laravel
1621225800
In this tutorial i will show you how to create zip file using zipArchive in laravel. Some times client’s have requirements to have functionalities like create zip file for documentation or images and download it.
So, at that time we can find many laravel packages to perform this task. But here, i am show you to how to create zip file in laravel using zipArchive without any package. Laravel provide ZipArchive class for create zip file in laravel,So i will use ZipArchive in laravel.
#laravel #ziparchive #how to create zip file using ziparchive in laravel #ziparchive in laravel #make zip in laravel #ziparchive laravel example
1625635800
Hello friends,
Today I will give you example of how to create multi language website in laravel. In this example or tutorial you can understand a concept of laravel multilingual website example demo. Also gain knowledge or learn about how to add multiple languages in laravel. it’s very simple example of laravel multi language with different list of language dropdown.
#how to create multi language website in laravel #laravel #laravel localization #laravel multiple language website #change website language dynamically in laravel #multilingual website
1595205933
Hello guys, sometimes while working on the large application, we need to create some very small modules like simple CRUD. So here in this article i will let you know laravel create model migration and controller in a single command.
We will run a single artisan command to create model. migration and controller. We can also create resource controller by giving parameter.
We can these model, migration and controller from three command but for time saving laravel provides feature to create thses three thing by one single command.
So for desired result open your terminal and run the following command.
php artisan make:model --migration --controller Product --resource
Here, we have create product model, migration and product controller with all the resources methods.
We can also write this command in the short form like below.
php artisan make:model -mc Product --resource
You can also write this command in a more short way like below.
php artisan make:model Product -mcr
**Note: **Here, m represents migration, c represents controller and r represents as resource.
After running the above command you will get the output like
Model created successfully
Created migration (migration file name with current date and migration name )
Controller created successfully.
You can also read the article to create to add a column in the existing table through migration by clicking on the link below.
#laravel #create controller resource and model in a command #laravel artisan command #laravel create model #laravel single command for model and migration #migration and controller