Custom Last updated: 2023-02-25
Let's you want to create an item but according to your needs
For example, a service or a map or fields in a specific way?
Of course we didn't forget that
You can use custom method
custom()->make('properties') // just a lable
->assign([
'column_name' => [
'name' => 'Custom Attribute Name',
'storeRule' => 'required|string',
'updateRule' => 'sometimes|nullable|unique:users,column_name,'.$this->id,
],
])
->view('customblade') // append your blade file
sample Blade Code
@php
$value = $page == 'create'?old('customdata'):$model->customdata;
@endphp
<div class="col-12">
<h1>Custom HTML</h1>
<div class="form-group">
<label for="column_name">column_name</label>
<input type="text" name="column_name" placeholder="بيانات مخصصة"
class="form-control border" value="{{ $value }}">
</div>
</div>
More Advanced Options To Use in Create , Edit , Show Pages
@if($page == 'create')
// write HTML And Bootstrap Data Here And you can write jquery or js or anything
@elseif($page == 'edit')
// use $model variable to retrive everything by model with current data and relations
@elseif($page == 'show')
// use $model variable to retrive everything by model with current data and relations
// {{$model->name}} OR {{$model->relationMethodName()->name}}
@endif
Method hasOneDatatable
to get value from other relationship in datatable list
Allocating fields from another table that you can do with this magic function, you can create one relationship and pull data according to a specific field from the table with which the relationship was made so that the data appears in the data table without the need to do many things
class Post extends model{
public function comment() {
return $this->hasOne(Comment::class);
}
}
custom()->make('Last Comment At')
->hasOneDatatable('comment.updated_at') // or other column
See This Image