1657021620
В этом разделе мы увидим приложение laravel 9 Filament crud (создание, чтение, обновление и удаление). Filament — это набор инструментов для быстрого создания красивых приложений с высоким стеком, предназначенных для людей.
У Filament есть несколько требований для запуска:
PHP 8.0+
Ларавель v8.0+
Livewire v2.0+
Установка свежего нового приложения laravel 9, поэтому зайдите в терминал, введите команду и создайте новое приложение laravel.
composer create-project laravel/laravel crud
Теперь вам нужно подключить приложение laravel к базе данных, поэтому откройте файл конфигурации .env и добавьте учетные данные базы данных, как показано ниже.
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=database_name
DB_USERNAME=database_user_name
DB_PASSWORD=database_password
Запустите ниже команду установки нити.
composer require filament/filament:"^2.0"
Создайте пользователя филамента для администратора.
php artisan make:filament-user
Дайте имя пользователя, адрес электронной почты и пароль.
Name:
> admin
Email address:
> admin@admin.com
Password:
>
Success! admin@admin.com may now log in at http://localhost/admin/login.
http://локальный:8000/admin/логин
Запустите приведенную ниже команду, чтобы создать модальный пост и миграцию.
php artisan make:model Post -m
create_posts_table.php
public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->string('slug')->unique();
$table->text('content');
$table->text('image')->nullable();
$table->boolean('is_published')->default(false);
$table->timestamps();
});
}
Приложение/Modal/Post.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
use HasFactory;
protected $fillable = [
'title',
'slug',
'content',
'image',
'is_published'
];
}
запустить миграцию
php artisan migrate
Запустите ниже, чтобы получить ресурс командного поста
php artisan make:filament-resource PostResource
Филамент/Ресурсы/PostResource.php
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\PostResource\Pages;
use App\Filament\Resources\PostResource\RelationManagers;
use App\Models\Post;
use Filament\Forms;
use Filament\Resources\Form;
use Filament\Resources\Resource;
use Filament\Resources\Table;
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\TextInput;
use Illuminate\Support\Str;
use Closure;
use Filament\Forms\Components\Card;
use Filament\Tables\Columns\TextColumn;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Toggle;
use Filament\Tables\Columns\BooleanColumn;
use Filament\Forms\Components\FileUpload;
use Filament\Tables\Columns\ImageColumn;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Filters\SelectFilter;
class PostResource extends Resource
{
protected static ?string $model = Post::class;
protected static ?string $navigationIcon = 'heroicon-o-collection';
public static function form(Form $form): Form
{
return $form
->schema([
Card::make()->schema([
TextInput::make('title')
->reactive()
->afterStateUpdated(function (Closure $set, $state) {
$set('slug', Str::slug($state));
})->required(),
TextInput::make('slug')->required(),
FileUpload::make('image')->image(),
RichEditor::make('content')->required(),
Toggle::make('is_published')
])
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('id')->sortable()->searchable(),
TextColumn::make('title')->limit(20)->sortable()->searchable(),
TextColumn::make('slug')->limit(50)->sortable()->searchable(),
ImageColumn::make('image'),
BooleanColumn::make('is_published')->searchable(),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListPosts::route('/'),
'create' => Pages\CreatePost::route('/create'),
'edit' => Pages\EditPost::route('/{record}/edit'),
];
}
}
Источник: https://larainfo.com
1627450200
Hello Guys,
Today I will show you how to create laravel AJAX CRUD example tutorial. In this tutorial we are implements ajax crud operation in laravel. Also perform insert, update, delete operation using ajax in laravel 6 and also you can use this ajax crud operation in laravel 6, laravel 7. In ajax crud operation we display records in datatable.
#laravel ajax crud example tutorial #ajax crud example in laravel #laravel crud example #laravel crud example with ajax #laravel #php
1621398581
Hello Friend,
As you know Laravel 8 already officially released and today I will show you how to create CRUD operation in laravel 8, I have already perform many CRUD operations in my previous post like CRUD operation in ajax, CRUD operation in laravel 6 etc. So, today I will give you laravel 8 CRUD application example.
#laravel #php #laravel 8 crud operation example #crud operation #laravel 8 crud tutorial #crud operation in laravel 8
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
1597727551
yajra datatables crud with ajax in laravel 7. In this post, i will show you how to create crud using datatable in laravel with ajax and model.
Now, i am going to show you how to install and use datatables in laravel 7 application. i will use jquery ajax crud with modals using datatables js in laravel 7. i will write easy code of jquery ajax request for crud with yajra datatable.
Use the below steps and create yajra DataTables crud with ajax in laravel:
Step 1: Install Laravel App For DataTable Crud
Step 2: Configuration .evn file
Step 3: Run Migration
Step 4: Install Yajra DataTables Package
Step 5: Add Fake Data into Database table
Step 6: Add Datatable Ajax Route
Stpe 7: Create DataTableController
Step 8: Create Ajax Datatable Blade View
Step 9: Start Development Server
https://www.tutsmake.com/laravel-7-6-install-yajra-datatables-example-tutorial/
#laravel 6 yajra datatables #yajra datatables laravel 6 example #laravel-datatables crud #yajra datatables laravel 7 #laravel 7 datatables #yajra datatables laravel
1657021620
В этом разделе мы увидим приложение laravel 9 Filament crud (создание, чтение, обновление и удаление). Filament — это набор инструментов для быстрого создания красивых приложений с высоким стеком, предназначенных для людей.
У Filament есть несколько требований для запуска:
PHP 8.0+
Ларавель v8.0+
Livewire v2.0+
Установка свежего нового приложения laravel 9, поэтому зайдите в терминал, введите команду и создайте новое приложение laravel.
composer create-project laravel/laravel crud
Теперь вам нужно подключить приложение laravel к базе данных, поэтому откройте файл конфигурации .env и добавьте учетные данные базы данных, как показано ниже.
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=database_name
DB_USERNAME=database_user_name
DB_PASSWORD=database_password
Запустите ниже команду установки нити.
composer require filament/filament:"^2.0"
Создайте пользователя филамента для администратора.
php artisan make:filament-user
Дайте имя пользователя, адрес электронной почты и пароль.
Name:
> admin
Email address:
> admin@admin.com
Password:
>
Success! admin@admin.com may now log in at http://localhost/admin/login.
http://локальный:8000/admin/логин
Запустите приведенную ниже команду, чтобы создать модальный пост и миграцию.
php artisan make:model Post -m
create_posts_table.php
public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->string('slug')->unique();
$table->text('content');
$table->text('image')->nullable();
$table->boolean('is_published')->default(false);
$table->timestamps();
});
}
Приложение/Modal/Post.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
use HasFactory;
protected $fillable = [
'title',
'slug',
'content',
'image',
'is_published'
];
}
запустить миграцию
php artisan migrate
Запустите ниже, чтобы получить ресурс командного поста
php artisan make:filament-resource PostResource
Филамент/Ресурсы/PostResource.php
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\PostResource\Pages;
use App\Filament\Resources\PostResource\RelationManagers;
use App\Models\Post;
use Filament\Forms;
use Filament\Resources\Form;
use Filament\Resources\Resource;
use Filament\Resources\Table;
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\TextInput;
use Illuminate\Support\Str;
use Closure;
use Filament\Forms\Components\Card;
use Filament\Tables\Columns\TextColumn;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Toggle;
use Filament\Tables\Columns\BooleanColumn;
use Filament\Forms\Components\FileUpload;
use Filament\Tables\Columns\ImageColumn;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Filters\SelectFilter;
class PostResource extends Resource
{
protected static ?string $model = Post::class;
protected static ?string $navigationIcon = 'heroicon-o-collection';
public static function form(Form $form): Form
{
return $form
->schema([
Card::make()->schema([
TextInput::make('title')
->reactive()
->afterStateUpdated(function (Closure $set, $state) {
$set('slug', Str::slug($state));
})->required(),
TextInput::make('slug')->required(),
FileUpload::make('image')->image(),
RichEditor::make('content')->required(),
Toggle::make('is_published')
])
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('id')->sortable()->searchable(),
TextColumn::make('title')->limit(20)->sortable()->searchable(),
TextColumn::make('slug')->limit(50)->sortable()->searchable(),
ImageColumn::make('image'),
BooleanColumn::make('is_published')->searchable(),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListPosts::route('/'),
'create' => Pages\CreatePost::route('/create'),
'edit' => Pages\EditPost::route('/{record}/edit'),
];
}
}
Источник: https://larainfo.com