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">
|
|
|
|
<i data-toggle="tooltip" data-placement="top" title="Edit" class="fa fa-pencil"></i>
|
|
|
|
</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').'">
|
|
|
|
<i data-toggle="tooltip" data-placement="top" title="Delete" class="fa fa-trash"></i>
|
|
|
|
</a>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|