tethys/app/Models/ModelTrait.php

37 lines
1.2 KiB
PHP
Raw Normal View History

2018-09-04 14:51:04 +00:00
<?php
namespace App\Models;
2018-09-06 15:58:54 +00:00
use Illuminate\Support\Facades\Auth;
2018-09-04 14:51:04 +00:00
trait ModelTrait
{
/**
* @return string
*/
public function getEditButtonAttribute($permission, $route)
{
2018-09-06 15:58:54 +00:00
if (Auth::user()->can($permission)) {
2018-09-04 14:51:04 +00:00
return '<a href="'.route($route, $this).'" class="btn btn-flat btn-default">
2019-04-18 11:16:50 +00:00
<i data-toggle="tooltip" data-placement="top" title="Edit" class="fas fa-pencil-ruler"></i>
2018-09-04 14:51:04 +00:00
</a>';
}
}
/**
* @return string
*/
public function getDeleteButtonAttribute($permission, $route)
{
2018-09-06 15:58:54 +00:00
if (Auth::user()->can($permission)) {
2018-09-04 14:51:04 +00:00
return '<a href="'.route($route, $this).'"
class="btn btn-flat btn-default" data-method="delete"
data-trans-button-cancel="'.trans('buttons.general.cancel').'"
data-trans-button-confirm="'.trans('buttons.general.crud.delete').'"
data-trans-title="'.trans('strings.backend.general.are_you_sure').'">
2019-04-18 11:16:50 +00:00
<i data-toggle="tooltip" data-placement="top" title="Delete" class="fas fa-trash"></i>
2018-09-04 14:51:04 +00:00
</a>';
}
}
}