Unverified Commit f3fee52a authored by ruchit-viitorcloud's avatar ruchit-viitorcloud Committed by GitHub

Merge branch 'master' into master

parents 952e30e3 a4956390
...@@ -17,8 +17,9 @@ trait AttributeClass ...@@ -17,8 +17,9 @@ trait AttributeClass
*/ */
public function getActionButtonsAttribute() public function getActionButtonsAttribute()
{ {
return '<div class="btn-group action-btn">'. return '<div class="btn-group action-btn">
//call your attribute functions here '.$this->getEditButtonAttribute(editPermission, editRoute).'
'</div>'; '.$this->getDeleteButtonAttribute(deletePermission, deleteRoute).'
</div>';
} }
} }
...@@ -2,14 +2,18 @@ ...@@ -2,14 +2,18 @@
namespace DummyNamespace; namespace DummyNamespace;
use App\Models\ModelTrait;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use DummyAttribute; use DummyAttribute;
use DummyRelationship; use DummyRelationship;
class DummyModel extends Model class DummyModel extends Model
{ {
use AttributeName, use ModelTrait,
RelationshipName; AttributeName,
RelationshipName {
// AttributeName::getEditButtonAttribute insteadof ModelTrait;
}
/** /**
* NOTE : If you want to implement Soft Deletes in this model, * NOTE : If you want to implement Soft Deletes in this model,
......
...@@ -45,6 +45,7 @@ class DummyRepoName extends BaseRepository ...@@ -45,6 +45,7 @@ class DummyRepoName extends BaseRepository
public function create(array $input) public function create(array $input)
{ {
$dummy_small_model_name = self::MODEL; $dummy_small_model_name = self::MODEL;
$dummy_small_model_name = new $dummy_small_model_name();
if ($dummy_small_model_name->save($input)) { if ($dummy_small_model_name->save($input)) {
return true; return true;
} }
......
...@@ -155,7 +155,7 @@ class BlogsController extends Controller ...@@ -155,7 +155,7 @@ class BlogsController extends Controller
if (is_numeric($tag)) { if (is_numeric($tag)) {
$tags_array[] = $tag; $tags_array[] = $tag;
} else { } else {
$newTag = BlogTag::create(['name'=>$tag, 'status'=>1, 'created_by'=>1]); $newTag = BlogTag::create(['name' => $tag, 'status' => 1, 'created_by' => 1]);
$tags_array[] = $newTag->id; $tags_array[] = $newTag->id;
} }
} }
......
...@@ -26,7 +26,7 @@ class VerifyJWTToken ...@@ -26,7 +26,7 @@ class VerifyJWTToken
} elseif ($e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException) { } elseif ($e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException) {
return response()->json(['token_invalid'], $e->getStatusCode()); return response()->json(['token_invalid'], $e->getStatusCode());
} else { } else {
return response()->json(['error'=>'Token is required']); return response()->json(['error' => 'Token is required']);
} }
} }
......
...@@ -106,6 +106,22 @@ class Generator ...@@ -106,6 +106,22 @@ class Generator
protected $update_permission; protected $update_permission;
protected $delete_permission; protected $delete_permission;
/**
* Routes
* 1. Edit Route
* 2. Store Route
* 3. Manage Route
* 4. Create Route
* 5. Update Route
* 6. Delete Route.
*/
protected $edit_route;
protected $store_route;
protected $index_route;
protected $create_route;
protected $update_route;
protected $delete_route;
/** /**
* Repository * Repository
* 1. Repository Name * 1. Repository Name
...@@ -206,6 +222,14 @@ class Generator ...@@ -206,6 +222,14 @@ class Generator
$this->update_permission = 'update-'.strtolower(str_singular($this->model)); $this->update_permission = 'update-'.strtolower(str_singular($this->model));
$this->delete_permission = 'delete-'.strtolower(str_singular($this->model)); $this->delete_permission = 'delete-'.strtolower(str_singular($this->model));
//Routes
$this->index_route = 'admin.'.strtolower(str_plural($this->model)).'.index';
$this->create_route = 'admin.'.strtolower(str_plural($this->model)).'.create';
$this->store_route = 'admin.'.strtolower(str_plural($this->model)).'.store';
$this->edit_route = 'admin.'.strtolower(str_plural($this->model)).'.edit';
$this->update_route = 'admin.'.strtolower(str_plural($this->model)).'.update';
$this->delete_route = 'admin.'.strtolower(str_plural($this->model)).'.destroy';
//Events //Events
$this->events = array_filter($input['event']); $this->events = array_filter($input['event']);
...@@ -342,11 +366,15 @@ class Generator ...@@ -342,11 +366,15 @@ class Generator
*/ */
public function createModel() public function createModel()
{ {
$this->createDirectory($this->getBasePath($this->attribute_namespace)); $this->createDirectory($this->getBasePath($this->removeFileNameFromEndOfNamespace($this->attribute_namespace)));
//Generate Attribute File //Generate Attribute File
$this->generateFile('Attribute', [ $this->generateFile('Attribute', [
'AttributeNamespace' => ucfirst($this->removeFileNameFromEndOfNamespace($this->attribute_namespace)), 'AttributeNamespace' => ucfirst($this->removeFileNameFromEndOfNamespace($this->attribute_namespace)),
'AttributeClass' => $this->attribute, 'AttributeClass' => $this->attribute,
'editPermission' => $this->edit_permission,
'editRoute' => $this->edit_route,
'deletePermission' => $this->delete_permission,
'deleteRoute' => $this->delete_route,
], lcfirst($this->attribute_namespace)); ], lcfirst($this->attribute_namespace));
//Generate Relationship File //Generate Relationship File
......
...@@ -101,7 +101,7 @@ abstract class Notification ...@@ -101,7 +101,7 @@ abstract class Notification
*/ */
public function setOptions(array $options) public function setOptions(array $options)
{ {
foreach ($options as $optionKey=>$option) { foreach ($options as $optionKey => $option) {
$methodName = 'set'.ucfirst($optionKey); $methodName = 'set'.ucfirst($optionKey);
$propertyName = '_'.$optionKey; $propertyName = '_'.$optionKey;
if (method_exists($methodName, $this)) { if (method_exists($methodName, $this)) {
......
...@@ -91,7 +91,7 @@ class SendEmail ...@@ -91,7 +91,7 @@ class SendEmail
break; break;
} }
// Send email code // Send email code
$message = ['data'=>$content]; $message = ['data' => $content];
return Mail::send(['html' => 'emails.template'], $message, function ($message) use ($data) { return Mail::send(['html' => 'emails.template'], $message, function ($message) use ($data) {
$message->to($data['to']); $message->to($data['to']);
......
...@@ -4,6 +4,7 @@ namespace App\Models\Access\Permission; ...@@ -4,6 +4,7 @@ namespace App\Models\Access\Permission;
use App\Models\Access\Permission\Traits\Attribute\PermissionAttribute; use App\Models\Access\Permission\Traits\Attribute\PermissionAttribute;
use App\Models\Access\Permission\Traits\Relationship\PermissionRelationship; use App\Models\Access\Permission\Traits\Relationship\PermissionRelationship;
use App\Models\ModelTrait;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
...@@ -12,7 +13,12 @@ use Illuminate\Database\Eloquent\SoftDeletes; ...@@ -12,7 +13,12 @@ use Illuminate\Database\Eloquent\SoftDeletes;
*/ */
class Permission extends Model class Permission extends Model
{ {
use PermissionRelationship, PermissionAttribute, SoftDeletes; use ModelTrait,
SoftDeletes,
PermissionAttribute,
PermissionRelationship {
// PermissionAttribute::getEditButtonAttribute insteadof ModelTrait;
}
/** /**
* The database table used by the model. * The database table used by the model.
......
...@@ -7,42 +7,14 @@ namespace App\Models\Access\Permission\Traits\Attribute; ...@@ -7,42 +7,14 @@ namespace App\Models\Access\Permission\Traits\Attribute;
*/ */
trait PermissionAttribute trait PermissionAttribute
{ {
/**
* @return string
*/
public function getEditButtonAttribute()
{
if (access()->allow('edit-permission')) {
return '<a class="btn btn-flat btn-default" href="'.route('admin.access.permission.edit', $this).'">
<i data-toggle="tooltip" data-placement="top" title="Edit" class="fa fa-pencil"></i>
</a>';
}
}
/**
* @return string
*/
public function getDeleteButtonAttribute()
{
if (access()->allow('delete-permission')) {
return '<a class="btn btn-flat btn-default" href="'.route('admin.access.permission.destroy', $this).'" 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>';
}
}
/** /**
* @return string * @return string
*/ */
public function getActionButtonsAttribute() public function getActionButtonsAttribute()
{ {
return '<div class="btn-group action-btn"> return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute().' '.$this->getEditButtonAttribute('edit-permission', 'admin.access.permission.edit').'
'.$this->getDeleteButtonAttribute().' '.$this->getDeleteButtonAttribute('delete-permission', 'admin.access.permission.destroy').'
</div>'; </div>';
} }
} }
...@@ -6,6 +6,7 @@ use App\Models\Access\Role\Traits\Attribute\RoleAttribute; ...@@ -6,6 +6,7 @@ use App\Models\Access\Role\Traits\Attribute\RoleAttribute;
use App\Models\Access\Role\Traits\Relationship\RoleRelationship; use App\Models\Access\Role\Traits\Relationship\RoleRelationship;
use App\Models\Access\Role\Traits\RoleAccess; use App\Models\Access\Role\Traits\RoleAccess;
use App\Models\Access\Role\Traits\Scope\RoleScope; use App\Models\Access\Role\Traits\Scope\RoleScope;
use App\Models\ModelTrait;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
...@@ -15,10 +16,14 @@ use Illuminate\Database\Eloquent\SoftDeletes; ...@@ -15,10 +16,14 @@ use Illuminate\Database\Eloquent\SoftDeletes;
class Role extends Model class Role extends Model
{ {
use RoleScope, use RoleScope,
ModelTrait,
RoleAccess, RoleAccess,
RoleAttribute, RoleAttribute,
RoleRelationship, RoleRelationship,
SoftDeletes; SoftDeletes {
RoleAttribute::getEditButtonAttribute insteadof ModelTrait;
RoleAttribute::getDeleteButtonAttribute insteadof ModelTrait;
}
/** /**
* The database table used by the model. * The database table used by the model.
......
...@@ -43,7 +43,7 @@ trait RoleAttribute ...@@ -43,7 +43,7 @@ trait RoleAttribute
public function getActionButtonsAttribute() public function getActionButtonsAttribute()
{ {
return '<div class="btn-group action-btn"> return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute().' '.$this->getEditButtonAttribute('edit-role', 'admin.access.role.edit').'
'.$this->getDeleteButtonAttribute().' '.$this->getDeleteButtonAttribute().'
</div>'; </div>';
} }
......
...@@ -4,14 +4,18 @@ namespace App\Models\BlogCategories; ...@@ -4,14 +4,18 @@ namespace App\Models\BlogCategories;
use App\Models\BlogCategories\Traits\Attribute\BlogCategoryAttribute; use App\Models\BlogCategories\Traits\Attribute\BlogCategoryAttribute;
use App\Models\BlogCategories\Traits\Relationship\BlogCategoryRelationship; use App\Models\BlogCategories\Traits\Relationship\BlogCategoryRelationship;
use App\Models\ModelTrait;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
class BlogCategory extends Model class BlogCategory extends Model
{ {
use BlogCategoryAttribute, use ModelTrait,
SoftDeletes, SoftDeletes,
BlogCategoryRelationship; BlogCategoryAttribute,
BlogCategoryRelationship {
// BlogCategoryAttribute::getEditButtonAttribute insteadof ModelTrait;
}
/** /**
* The database table used by the model. * The database table used by the model.
......
...@@ -7,41 +7,14 @@ namespace App\Models\BlogCategories\Traits\Attribute; ...@@ -7,41 +7,14 @@ namespace App\Models\BlogCategories\Traits\Attribute;
*/ */
trait BlogCategoryAttribute trait BlogCategoryAttribute
{ {
/**
* @return string
*/
public function getEditButtonAttribute()
{
if (access()->allow('edit-blog-category')) {
return '<a class="btn btn-flat btn-default" href="'.route('admin.blogcategories.edit', $this).'">
<i data-toggle="tooltip" data-placement="top" title="'.trans('buttons.general.crud.edit').'" class="fa fa-pencil"></i>
</a>';
}
}
/**
* @return string
*/
public function getDeleteButtonAttribute()
{
if (access()->allow('delete-blog-category')) {
return '<a class="btn btn-flat btn-default" href="'.route('admin.blogcategories.destroy', $this).'" 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>';
}
}
/** /**
* @return string * @return string
*/ */
public function getActionButtonsAttribute() public function getActionButtonsAttribute()
{ {
return '<div class="btn-group action-btn"> return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute().' '.$this->getEditButtonAttribute('edit-blog-category', 'admin.blogcategories.edit').'
'.$this->getDeleteButtonAttribute().' '.$this->getDeleteButtonAttribute('delete-blog-category', 'admin.blogcategories.destroy').'
</div>'; </div>';
} }
} }
...@@ -4,14 +4,18 @@ namespace App\Models\BlogTags; ...@@ -4,14 +4,18 @@ namespace App\Models\BlogTags;
use App\Models\BlogTags\Traits\Attribute\BlogTagAttribute; use App\Models\BlogTags\Traits\Attribute\BlogTagAttribute;
use App\Models\BlogTags\Traits\Relationship\BlogTagRelationship; use App\Models\BlogTags\Traits\Relationship\BlogTagRelationship;
use App\Models\ModelTrait;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
class BlogTag extends Model class BlogTag extends Model
{ {
use BlogTagAttribute, use ModelTrait,
SoftDeletes, SoftDeletes,
BlogTagRelationship; BlogTagAttribute,
BlogTagRelationship{
// BlogTagAttribute::getEditButtonAttribute insteadof ModelTrait;
}
/** /**
* The database table used by the model. * The database table used by the model.
......
...@@ -7,41 +7,14 @@ namespace App\Models\BlogTags\Traits\Attribute; ...@@ -7,41 +7,14 @@ namespace App\Models\BlogTags\Traits\Attribute;
*/ */
trait BlogTagAttribute trait BlogTagAttribute
{ {
/**
* @return string
*/
public function getEditButtonAttribute()
{
if (access()->allow('edit-blog-tag')) {
return '<a class="btn btn-flat btn-default" href="'.route('admin.blogtags.edit', $this).'">
<i data-toggle="tooltip" data-placement="top" title="'.trans('buttons.general.crud.edit').'" class="fa fa-pencil"></i>
</a>';
}
}
/**
* @return string
*/
public function getDeleteButtonAttribute()
{
if (access()->allow('delete-blog-tag')) {
return '<a class="btn btn-flat btn-default" href="'.route('admin.blogtags.destroy', $this).'" 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="'.trans('buttons.general.crud.delete').'" class="fa fa-trash"></i>
</a>';
}
}
/** /**
* @return string * @return string
*/ */
public function getActionButtonsAttribute() public function getActionButtonsAttribute()
{ {
return '<div class="btn-group action-btn"> return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute().' '.$this->getEditButtonAttribute('edit-blog-tag', 'admin.blogtags.edit').'
'.$this->getDeleteButtonAttribute().' '.$this->getDeleteButtonAttribute('delete-blog-tag', 'admin.blogtags.destroy').'
</div>'; </div>';
} }
} }
...@@ -4,14 +4,18 @@ namespace App\Models\Blogs; ...@@ -4,14 +4,18 @@ namespace App\Models\Blogs;
use App\Models\Blogs\Traits\Attribute\BlogAttribute; use App\Models\Blogs\Traits\Attribute\BlogAttribute;
use App\Models\Blogs\Traits\Relationship\BlogRelationship; use App\Models\Blogs\Traits\Relationship\BlogRelationship;
use App\Models\ModelTrait;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
class Blog extends Model class Blog extends Model
{ {
use BlogAttribute, use ModelTrait,
BlogRelationship, SoftDeletes,
SoftDeletes; BlogAttribute,
BlogRelationship {
// BlogAttribute::getEditButtonAttribute insteadof ModelTrait;
}
/** /**
* The database table used by the model. * The database table used by the model.
......
...@@ -7,42 +7,14 @@ namespace App\Models\Blogs\Traits\Attribute; ...@@ -7,42 +7,14 @@ namespace App\Models\Blogs\Traits\Attribute;
*/ */
trait BlogAttribute trait BlogAttribute
{ {
/**
* @return string
*/
public function getEditButtonAttribute()
{
if (access()->allow('edit-blog')) {
return '<a href="'.route('admin.blogs.edit', $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()
{
if (access()->allow('delete-blog')) {
return '<a href="'.route('admin.blogs.destroy', $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>';
}
}
/** /**
* @return string * @return string
*/ */
public function getActionButtonsAttribute() public function getActionButtonsAttribute()
{ {
return '<div class="btn-group action-btn">'. return '<div class="btn-group action-btn">'.
$this->getEditButtonAttribute(). $this->getEditButtonAttribute('edit-blog', 'admin.blogs.edit').
$this->getDeleteButtonAttribute(). $this->getDeleteButtonAttribute('delete-blog', 'admin.blogs.destroy').
'</div>'; '</div>';
} }
} }
...@@ -3,13 +3,17 @@ ...@@ -3,13 +3,17 @@
namespace App\Models\CMSPages; namespace App\Models\CMSPages;
use App\Models\CMSPages\Traits\Attribute\CMSPageAttribute; use App\Models\CMSPages\Traits\Attribute\CMSPageAttribute;
use App\Models\ModelTrait;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
class CMSPage extends Model class CMSPage extends Model
{ {
use CMSPageAttribute, use ModelTrait,
SoftDeletes; SoftDeletes,
CMSPageAttribute {
// CMSPageAttribute::getEditButtonAttribute insteadof ModelTrait;
}
/** /**
* The database table used by the model. * The database table used by the model.
......
...@@ -7,41 +7,14 @@ namespace App\Models\CMSPages\Traits\Attribute; ...@@ -7,41 +7,14 @@ namespace App\Models\CMSPages\Traits\Attribute;
*/ */
trait CMSPageAttribute trait CMSPageAttribute
{ {
/**
* @return string
*/
public function getEditButtonAttribute()
{
if (access()->allow('edit-cms-pages')) {
return '<a class="btn btn-flat btn-default" href="'.route('admin.cmspages.edit', $this).'">
<i data-toggle="tooltip" data-placement="top" title="'.trans('buttons.general.crud.edit').'" class="fa fa-pencil"></i>
</a>';
}
}
/**
* @return string
*/
public function getDeleteButtonAttribute()
{
if (access()->allow('delete-cms-pages')) {
return '<a class="btn btn-flat btn-default" href="'.route('admin.cmspages.destroy', $this).'" 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>';
}
}
/** /**
* @return string * @return string
*/ */
public function getActionButtonsAttribute() public function getActionButtonsAttribute()
{ {
return '<div class="btn-group action-btn"> return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute().' '.$this->getEditButtonAttribute('edit-cms-pages', 'admin.cmspages.edit').'
'.$this->getDeleteButtonAttribute().' '.$this->getDeleteButtonAttribute('delete-cms-pages', 'admin.cmspages.destroy').'
</div>'; </div>';
} }
} }
...@@ -3,13 +3,17 @@ ...@@ -3,13 +3,17 @@
namespace App\Models\EmailTemplates; namespace App\Models\EmailTemplates;
use App\Models\EmailTemplates\Traits\Attribute\EmailTemplateAttribute; use App\Models\EmailTemplates\Traits\Attribute\EmailTemplateAttribute;
use App\Models\ModelTrait;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
class EmailTemplate extends Model class EmailTemplate extends Model
{ {
use EmailTemplateAttribute, use ModelTrait,
SoftDeletes; SoftDeletes,
EmailTemplateAttribute {
// EmailTemplateAttribute::getEditButtonAttribute insteadof ModelTrait;
}
/** /**
* The database table used by the model. * The database table used by the model.
......
...@@ -7,36 +7,11 @@ namespace App\Models\EmailTemplates\Traits\Attribute; ...@@ -7,36 +7,11 @@ namespace App\Models\EmailTemplates\Traits\Attribute;
*/ */
trait EmailTemplateAttribute trait EmailTemplateAttribute
{ {
/**
* @return string
*/
public function getEditButtonAttribute()
{
if (access()->allow('edit-email-template')) {
return '<a class="btn btn-flat btn-default" href="'.route('admin.emailtemplates.edit', $this).'" class="btn btn-xs btn-primary"><i class="fa fa-pencil" data-toggle="tooltip" data-placement="top" title="'.trans('buttons.general.crud.edit').'"></i></a> ';
}
}
/**
* @return string
*/
public function getDeleteButtonAttribute()
{
if (access()->allow('delete-email-template')) {
return '<a href="'.route('admin.emailtemplates.destroy', $this).'"
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').'"
class="btn btn-xs btn-danger"><i class="fa fa-times" data-toggle="tooltip" data-placement="top" title="'.trans('buttons.general.crud.delete').'"></i></a>';
}
}
/** /**
* @return string * @return string
*/ */
public function getActionButtonsAttribute() public function getActionButtonsAttribute()
{ {
return '<div class="btn-group action-btn">'.$this->getEditButtonAttribute().'</div>'; return '<div class="btn-group action-btn">'.$this->getEditButtonAttribute('edit-email-template', 'admin.emailtemplates.edit').'</div>';
} }
} }
...@@ -3,12 +3,17 @@ ...@@ -3,12 +3,17 @@
namespace App\Models\Faqs; namespace App\Models\Faqs;
use App\Models\Faqs\Traits\Attribute\FaqAttribute; use App\Models\Faqs\Traits\Attribute\FaqAttribute;
use App\Models\ModelTrait;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
class Faq extends Model class Faq extends Model
{ {
use FaqAttribute, SoftDeletes; use ModelTrait,
SoftDeletes,
FaqAttribute {
// FaqAttribute::getEditButtonAttribute insteadof ModelTrait;
}
/** /**
* The database table used by the model. * The database table used by the model.
......
...@@ -7,34 +7,6 @@ namespace App\Models\Faqs\Traits\Attribute; ...@@ -7,34 +7,6 @@ namespace App\Models\Faqs\Traits\Attribute;
*/ */
trait FaqAttribute trait FaqAttribute
{ {
/**
* @return string
*/
public function getEditButtonAttribute()
{
if (access()->allow('edit-faq')) {
return '<a href="'.route('admin.faqs.edit', $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()
{
if (access()->allow('delete-faq')) {
return '<a href="'.route('admin.faqs.destroy', $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>';
}
}
/** /**
* @return string * @return string
*/ */
...@@ -83,8 +55,8 @@ trait FaqAttribute ...@@ -83,8 +55,8 @@ trait FaqAttribute
public function getActionButtonsAttribute() public function getActionButtonsAttribute()
{ {
return '<div class="btn-group action-btn">'. return '<div class="btn-group action-btn">'.
$this->getEditButtonAttribute(). $this->getEditButtonAttribute('edit-faq', 'admin.faqs.edit').
$this->getDeleteButtonAttribute(). $this->getDeleteButtonAttribute('delete-faq', 'admin.faqs.destroy').
$this->getStatusButtonAttribute(). $this->getStatusButtonAttribute().
'</div>'; '</div>';
} }
......
...@@ -3,13 +3,17 @@ ...@@ -3,13 +3,17 @@
namespace App\Models\Menu; namespace App\Models\Menu;
use App\Models\Menu\Traits\Attribute\MenuAttribute; use App\Models\Menu\Traits\Attribute\MenuAttribute;
use App\Models\ModelTrait;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
class Menu extends Model class Menu extends Model
{ {
use MenuAttribute, use ModelTrait,
SoftDeletes; SoftDeletes,
MenuAttribute {
// MenuAttribute::getEditButtonAttribute insteadof ModelTrait;
}
/** /**
* The database table used by the model. * The database table used by the model.
......
...@@ -7,41 +7,14 @@ namespace App\Models\Menu\Traits\Attribute; ...@@ -7,41 +7,14 @@ namespace App\Models\Menu\Traits\Attribute;
*/ */
trait MenuAttribute trait MenuAttribute
{ {
/**
* @return string
*/
public function getEditButtonAttribute()
{
if (access()->allow('edit-menu')) {
return '<a class="btn btn-flat btn-default" href="'.route('admin.menus.edit', $this).'">
<i data-toggle="tooltip" data-placement="top" title="'.trans('buttons.general.crud.edit').'" class="fa fa-pencil"></i>
</a>';
}
}
/**
* @return string
*/
public function getDeleteButtonAttribute()
{
if (access()->allow('delete-menu')) {
return '<a class="btn btn-flat btn-default" href="'.route('admin.menus.destroy', $this).'" 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>';
}
}
/** /**
* @return string * @return string
*/ */
public function getActionButtonsAttribute() public function getActionButtonsAttribute()
{ {
return '<div class="btn-group action-btn"> return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute().' '.$this->getEditButtonAttribute('edit-menu', 'admin.menus.edit').'
'.$this->getDeleteButtonAttribute().' '.$this->getDeleteButtonAttribute('delete-menu', 'admin.menus.destroy').'
</div>'; </div>';
} }
} }
<?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>';
}
}
}
...@@ -53,7 +53,7 @@ class PasswordResetRepository extends BaseRepository ...@@ -53,7 +53,7 @@ class PasswordResetRepository extends BaseRepository
*/ */
public function update($attributes) public function update($attributes)
{ {
$token = ['token'=>$attributes['token']]; $token = ['token' => $attributes['token']];
return $this->query()->where('email', $attributes['email'])->update($attributes); return $this->query()->where('email', $attributes['email'])->update($attributes);
} }
......
...@@ -57,7 +57,7 @@ class UserRepository extends BaseRepository ...@@ -57,7 +57,7 @@ class UserRepository extends BaseRepository
*/ */
public function resetpassword($data) public function resetpassword($data)
{ {
$pass = ['password'=>bcrypt($data['password'])]; $pass = ['password' => bcrypt($data['password'])];
return $this->query()->where('email', $data['email'])->update($pass); return $this->query()->where('email', $data['email'])->update($pass);
} }
...@@ -72,13 +72,13 @@ class UserRepository extends BaseRepository ...@@ -72,13 +72,13 @@ class UserRepository extends BaseRepository
return $this->query() return $this->query()
->select('first_name', 'last_name', 'email', 'address', 'country_id', 'state_id', 'city_id', 'zip_code', 'ssn', 'status', 'created_at', 'updated_at') ->select('first_name', 'last_name', 'email', 'address', 'country_id', 'state_id', 'city_id', 'zip_code', 'ssn', 'status', 'created_at', 'updated_at')
->where('id', $id) ->where('id', $id)
->with(['country'=> function ($query) { ->with(['country' => function ($query) {
$query->select('id', 'country'); $query->select('id', 'country');
}]) }])
->with(['state'=> function ($query) { ->with(['state' => function ($query) {
$query->select('id', 'state'); $query->select('id', 'state');
}]) }])
->with(['city'=> function ($query) { ->with(['city' => function ($query) {
$query->select('id', 'city'); $query->select('id', 'city');
}]) }])
->get() ->get()
...@@ -150,7 +150,7 @@ class UserRepository extends BaseRepository ...@@ -150,7 +150,7 @@ class UserRepository extends BaseRepository
**/ **/
public function confirmUser($email) public function confirmUser($email)
{ {
$confirmed = ['confirmed'=>'1']; $confirmed = ['confirmed' => '1'];
return $this->query()->where('email', $email)->update($confirmed); return $this->query()->where('email', $email)->update($confirmed);
} }
......
...@@ -53,7 +53,7 @@ class RoleRepository extends BaseRepository ...@@ -53,7 +53,7 @@ class RoleRepository extends BaseRepository
DB::raw("GROUP_CONCAT( DISTINCT permissions.display_name SEPARATOR '<br/>') as permission_name"), DB::raw("GROUP_CONCAT( DISTINCT permissions.display_name SEPARATOR '<br/>') as permission_name"),
DB::raw('(SELECT COUNT(role_user.id) FROM role_user LEFT JOIN users ON role_user.user_id = users.id WHERE role_user.role_id = roles.id AND users.deleted_at IS NULL) AS userCount'), DB::raw('(SELECT COUNT(role_user.id) FROM role_user LEFT JOIN users ON role_user.user_id = users.id WHERE role_user.role_id = roles.id AND users.deleted_at IS NULL) AS userCount'),
]) ])
->groupBy('roles.id'); ->groupBy(config('access.roles_table').'.id', config('access.roles_table').'.name', config('access.roles_table').'.all', config('access.roles_table').'.sort');
} }
/** /**
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment