ifox
02/05/2022, 11:50 PMkalle
02/05/2022, 11:50 PMphp
# app/Http/Controllers/Admin/YourController.php
...
public function additionalTableActions()
{
return [
'addNew' => [ // Action name.
'name' => 'Add new', // Button action title.
'variant' => 'primary', // Button style variant. Available variants; primary, secondary, action, editor, validate, aslink, aslink-grey, warning, ghost, outline, tertiary
'size' => 'small', // Button size. Available sizes; small
'link' => route('yourcontroller.someAction'), // Button action link.
'target' => '', // Leave it blank for self.
'type' => 'a', // Leave it blank for "button".
]
];
}
After this create custom controller and add new record.amargoCactus
02/05/2022, 11:51 PMifox
02/05/2022, 11:52 PMifox
02/05/2022, 11:53 PMamargoCactus
02/05/2022, 11:54 PMamargoCactus
02/05/2022, 11:54 PMamargoCactus
02/05/2022, 11:55 PMamargoCactus
02/05/2022, 11:55 PMamargoCactus
02/05/2022, 11:55 PMifox
02/05/2022, 11:56 PMamargoCactus
02/06/2022, 12:02 AMifox
02/06/2022, 12:03 AMamargoCactus
02/06/2022, 4:07 AMamargoCactus
02/06/2022, 4:15 AMamargoCactus
02/06/2022, 5:53 AMprotected $indexColumns = [
'image' => [
'thumb' => true, // image column
'variant' => [
'role' => 'cover',
'crop' => 'default',
],
],
'title' => [ // field column
'title' => 'Title',
'field' => 'title',
],
'subtitle' => [
'title' => 'Subtitle',
'field' => 'subtitle',
],
'description' => [
'title' => 'Description',
'field' => 'description',
],
];Karo
02/06/2022, 7:30 AMamargoCactus
02/06/2022, 12:19 PMifox
02/06/2022, 12:21 PMamargoCactus
02/06/2022, 12:32 PMamargoCactus
02/06/2022, 12:33 PM<?php
namespace App\Models;
use A17\Twill\Models\Behaviors\HasMedias;
use A17\Twill\Models\Behaviors\HasRevisions;
use A17\Twill\Models\Behaviors\HasPosition;
use A17\Twill\Models\Behaviors\Sortable;
use A17\Twill\Models\Model;
class Service extends Model implements Sortable
{
use HasMedias, HasRevisions, HasPosition;
protected $fillable = [
'published',
'title',
'subtitle',
'image',
'description',
'position',
];
public $mediasParams = [
'cover' => [
'default' => [
[
'name' => 'default',
'ratio' => 16 / 9,
],
],
'mobile' => [
[
'name' => 'mobile',
'ratio' => 1,
],
],
'flexible' => [
[
'name' => 'free',
'ratio' => 0,
],
[
'name' => 'landscape',
'ratio' => 16 / 9,
],
[
'name' => 'portrait',
'ratio' => 3 / 5,
],
],
],
];
}amargoCactus
02/06/2022, 12:33 PMamargoCactus
02/06/2022, 12:33 PM@extends('twill::layouts.form')
@section('contentFields')
@formField('input', [
'name' => 'subtitle',
'label' => 'Sub Title',
'maxlength' => 191
])
@formField('input', [
'name' => 'description',
'label' => 'Description',
'type' => 'textarea',
'rows' => 3
])
@formField('medias', [
'name' => 'image',
'label' => 'Image',
])
@stopamargoCactus
02/06/2022, 12:33 PMifox
02/06/2022, 12:34 PMifox
02/06/2022, 12:34 PM'name' => 'cover'amargoCactus
02/06/2022, 12:37 PMamargoCactus
02/06/2022, 12:37 PMamargoCactus
02/06/2022, 12:37 PMifox
02/06/2022, 12:37 PM