Created
January 26, 2018 09:50
-
-
Save bvipul/8332d51b639ff16499e1de4d55354005 to your computer and use it in GitHub Desktop.
Model Trait
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Models; | |
trait ModelTrait | |
{ | |
/** | |
* @return string | |
*/ | |
public function getEditButtonAttribute($permission, $route) | |
{ | |
if (access()->allow($permission)) { | |
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) | |
{ | |
if (access()->allow($permission)) { | |
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>'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment