Commit de5ba46e authored by Viral Solani's avatar Viral Solani

add basemodel

parent f84e0ef6
......@@ -2,18 +2,19 @@
namespace App\Http\Controllers\Backend\Access\User;
use App\Models\Access\User\User;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Access\User\CreateUserRequest;
use App\Http\Requests\Backend\Access\User\DeleteUserRequest;
use App\Models\Access\Permission\Permission;
use App\Repositories\Backend\Access\Role\RoleRepository;
use App\Repositories\Backend\Access\User\UserRepository;
use App\Http\Requests\Backend\Access\User\EditUserRequest;
use App\Http\Requests\Backend\Access\User\ManageUserRequest;
use App\Http\Requests\Backend\Access\User\ShowUserRequest;
use App\Http\Requests\Backend\Access\User\StoreUserRequest;
use App\Http\Requests\Backend\Access\User\CreateUserRequest;
use App\Http\Requests\Backend\Access\User\DeleteUserRequest;
use App\Http\Requests\Backend\Access\User\ManageUserRequest;
use App\Http\Requests\Backend\Access\User\UpdateUserRequest;
use App\Models\Access\User\User;
use App\Repositories\Backend\Access\Role\RoleRepository;
use App\Repositories\Backend\Access\User\UserRepository;
use Illuminate\Support\Facades\DB;
/**
* Class UserController.
......@@ -94,7 +95,6 @@ class UserController extends Controller
*/
public function edit(User $user, EditUserRequest $request)
{
//@todo move queries in to repositery
$userPermissions = DB::table('permission_user')->where('user_id', $user->id)->pluck('permission_id', 'permission_id')->toArray();
$permissions = DB::table('permissions')->pluck('display_name', 'id')->toArray();
ksort($userPermissions);
......
......@@ -2,12 +2,12 @@
namespace App\Models\Access\PasswordReset;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
/**
* Password reset table model.
*/
class PasswordReset extends Model
class PasswordReset extends BaseModel
{
public $timestamps = false;
protected $table = 'password_resets';
......
......@@ -5,13 +5,13 @@ namespace App\Models\Access\Permission;
use App\Models\Access\Permission\Traits\Attribute\PermissionAttribute;
use App\Models\Access\Permission\Traits\Relationship\PermissionRelationship;
use App\Models\ModelTrait;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class Permission.
*/
class Permission extends Model
class Permission extends BaseModel
{
use ModelTrait,
SoftDeletes,
......
......@@ -7,13 +7,13 @@ use App\Models\Access\Role\Traits\Relationship\RoleRelationship;
use App\Models\Access\Role\Traits\RoleAccess;
use App\Models\Access\Role\Traits\Scope\RoleScope;
use App\Models\ModelTrait;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class Role.
*/
class Role extends Model
class Role extends BaseModel
{
use RoleScope,
ModelTrait,
......
......@@ -2,12 +2,12 @@
namespace App\Models\Access\User;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
/**
* Class SocialLogin.
*/
class SocialLogin extends Model
class SocialLogin extends BaseModel
{
/**
* The database table used by the model.
......
......@@ -9,6 +9,7 @@ use App\Models\Access\User\Traits\UserAccess;
use App\Models\Access\User\Traits\UserSendPasswordReset;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Notifications\Notifiable;
/**
......
<?php namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class BaseModel extends Model
{
/**
* Generate drop-down select data with basic IDs
*
* @param null $id
* @param null $val
* @return array
*/
public static function getSelectData($id = null, $val = null)
{
$collection = parent::all();
return self::getItems($collection);
}
/**
* Generate items for drop-down select data with basic IDs
*
* @param $collection
* @return array
*/
public static function getItems($collection)
{
$items = array();
foreach($collection as $model)
{
$items[$model->id] = [
'id' => $model->id,
'name' => $model->name,
'model' => $model,
];
}
foreach($items as $id => $item)
{
if(isset(static::$selectHTMLFormat) && static::$selectHTMLFormat !== '')
{
$items[$item['id']] = static::generateSelectName($item['model'], static::$selectHTMLFormat);
}
else
{
$items[$item['id']] = $item['name'];
}
}
return $items;
}
}
......@@ -2,13 +2,13 @@
namespace App\Models\BlogCategories;
use App\Models\BlogCategories\Traits\Attribute\BlogCategoryAttribute;
use App\Models\BlogCategories\Traits\Relationship\BlogCategoryRelationship;
use App\Models\BaseModel;
use App\Models\ModelTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Models\BlogCategories\Traits\Attribute\BlogCategoryAttribute;
use App\Models\BlogCategories\Traits\Relationship\BlogCategoryRelationship;
class BlogCategory extends Model
class BlogCategory extends BaseModel
{
use ModelTrait,
SoftDeletes,
......
......@@ -2,9 +2,9 @@
namespace App\Models\BlogMapCategories;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
class BlogMapCategory extends Model
class BlogMapCategory extends BaseModel
{
/**
* The database table used by the model.
......
......@@ -2,9 +2,9 @@
namespace App\Models\BlogMapTags;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
class BlogMapTag extends Model
class BlogMapTag extends BaseModel
{
/**
* The database table used by the model.
......
......@@ -5,10 +5,10 @@ namespace App\Models\BlogTags;
use App\Models\BlogTags\Traits\Attribute\BlogTagAttribute;
use App\Models\BlogTags\Traits\Relationship\BlogTagRelationship;
use App\Models\ModelTrait;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
use Illuminate\Database\Eloquent\SoftDeletes;
class BlogTag extends Model
class BlogTag extends BaseModel
{
use ModelTrait,
SoftDeletes,
......
......@@ -5,10 +5,10 @@ namespace App\Models\Blogs;
use App\Models\Blogs\Traits\Attribute\BlogAttribute;
use App\Models\Blogs\Traits\Relationship\BlogRelationship;
use App\Models\ModelTrait;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
use Illuminate\Database\Eloquent\SoftDeletes;
class Blog extends Model
class Blog extends BaseModel
{
use ModelTrait,
SoftDeletes,
......
......@@ -3,9 +3,9 @@
namespace App\Models\Cities;
use App\Models\Cities\Traits\Relationship\CityRelationship;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
class City extends Model
class City extends BaseModel
{
use CityRelationship;
/**
......
......@@ -2,9 +2,9 @@
namespace App\Models\Countries;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
class Country extends Model
class Country extends BaseModel
{
/**
* The database table used by the model.
......
......@@ -2,9 +2,9 @@
namespace App\Models\EmailTemplatePlaceholders;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
class EmailTemplatePlaceholder extends Model
class EmailTemplatePlaceholder extends BaseModel
{
/**
* The database table used by the model.
......
......@@ -2,9 +2,9 @@
namespace App\Models\EmailTemplateTypes;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
class EmailTemplateType extends Model
class EmailTemplateType extends BaseModel
{
/**
* The database table used by the model.
......
......@@ -4,10 +4,10 @@ namespace App\Models\EmailTemplates;
use App\Models\EmailTemplates\Traits\Attribute\EmailTemplateAttribute;
use App\Models\ModelTrait;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
use Illuminate\Database\Eloquent\SoftDeletes;
class EmailTemplate extends Model
class EmailTemplate extends BaseModel
{
use ModelTrait,
SoftDeletes,
......
......@@ -4,10 +4,10 @@ namespace App\Models\Faqs;
use App\Models\Faqs\Traits\Attribute\FaqAttribute;
use App\Models\ModelTrait;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
use Illuminate\Database\Eloquent\SoftDeletes;
class Faq extends Model
class Faq extends BaseModel
{
use ModelTrait,
SoftDeletes,
......
......@@ -3,13 +3,13 @@
namespace App\Models\History;
use App\Models\History\Traits\Relationship\HistoryRelationship;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
/**
* Class History
* package App.
*/
class History extends Model
class History extends BaseModel
{
use HistoryRelationship;
......
......@@ -2,13 +2,13 @@
namespace App\Models\History;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
/**
* Class HistoryType
* package App.
*/
class HistoryType extends Model
class HistoryType extends BaseModel
{
/**
* The database table used by the model.
......
......@@ -2,9 +2,9 @@
namespace App\Models\Notification;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
class Notification extends Model
class Notification extends BaseModel
{
/**
* The database table used by the model.
......
......@@ -2,12 +2,12 @@
namespace App\Models\Page;
use App\Models\BaseModel;
use App\Models\ModelTrait;
use App\Models\Page\Traits\Attribute\PageAttribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Models\Page\Traits\Attribute\PageAttribute;
class Page extends Model
class Page extends BaseModel
{
use ModelTrait,
SoftDeletes,
......
......@@ -2,9 +2,9 @@
namespace App\Models\Settings;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
class Setting extends Model
class Setting extends BaseModel
{
/**
* The database table used by the model.
......
......@@ -3,9 +3,9 @@
namespace App\Models\States;
use App\Models\States\Traits\Relationship\StateRelationship;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
class State extends Model
class State extends BaseModel
{
use StateRelationship;
/**
......
......@@ -2,13 +2,13 @@
namespace App\Models\System;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
/**
* Class Session
* package App.
*/
class Session extends Model
class Session extends BaseModel
{
/**
* The database table used by the model.
......
......@@ -5,7 +5,7 @@ namespace App\Repositories\Api\CmsPage;
use App\Exceptions\GeneralException;
use App\Models\CMSPages\CMSPage;
use App\Repositories\BaseRepository;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
/**
* Class CmsPageRepository.
......
......@@ -4,7 +4,7 @@ namespace App\Repositories\Api\Role;
use App\Models\Access\Role\Role;
use App\Repositories\BaseRepository;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
/**
* Class RoleRepository.
......
......@@ -4,7 +4,7 @@ namespace App\Repositories\Api\User;
use App\Models\Access\PasswordReset\PasswordReset;
use App\Repositories\BaseRepository;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
/**
* Class PermissionRepository.
......
......@@ -6,7 +6,7 @@ use App\Mail\ConfirmAcoountMail;
use App\Models\Access\User\User;
use App\Repositories\Backend\Access\Role\RoleRepository;
use App\Repositories\BaseRepository;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
/**
* Class PermissionRepository.
......
......@@ -9,7 +9,7 @@ use App\Exceptions\GeneralException;
use App\Models\Access\Permission\Permission;
use App\Repositories\BaseRepository;
use DB;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
/**
* Class PermissionRepository.
......
......@@ -8,7 +8,7 @@ use App\Events\Backend\Access\Role\RoleUpdated;
use App\Exceptions\GeneralException;
use App\Models\Access\Role\Role;
use App\Repositories\BaseRepository;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
use Illuminate\Support\Facades\DB;
/**
......
......@@ -14,7 +14,7 @@ use App\Exceptions\GeneralException;
use App\Models\Access\User\User;
use App\Repositories\Backend\Access\Role\RoleRepository;
use App\Repositories\BaseRepository;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
......
......@@ -9,7 +9,7 @@ use App\Exceptions\GeneralException;
use App\Models\BlogCategories\BlogCategory;
use App\Repositories\BaseRepository;
use DB;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
/**
* Class BlogCategoriesRepository.
......
......@@ -9,7 +9,7 @@ use App\Exceptions\GeneralException;
use App\Models\BlogTags\BlogTag;
use App\Repositories\BaseRepository;
use DB;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
/**
* Class BlogTagsRepository.
......
......@@ -13,7 +13,7 @@ use App\Models\Blogs\Blog;
use App\Repositories\BaseRepository;
use Carbon\Carbon;
use DB;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
/**
* Class BlogsRepository.
......
......@@ -8,7 +8,7 @@ use App\Exceptions\GeneralException;
use App\Models\EmailTemplates\EmailTemplate;
use App\Repositories\BaseRepository;
use DB;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
/**
* Class EmailTemplatesRepository.
......
......@@ -5,7 +5,7 @@ namespace App\Repositories\Backend\Faqs;
use App\Exceptions\GeneralException;
use App\Models\Faqs\Faq;
use App\Repositories\BaseRepository;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
/**
* Class FaqsRepository.
......
......@@ -9,7 +9,7 @@ use App\Exceptions\GeneralException;
use App\Models\Page\Page;
use App\Repositories\BaseRepository;
use DB;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
/**
* Class PagesRepository.
......
......@@ -6,7 +6,7 @@ use App\Exceptions\GeneralException;
use App\Models\Settings\Setting;
use App\Repositories\BaseRepository;
use DB;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
/**
* Class SettingsRepository.
......
......@@ -5,7 +5,7 @@ namespace App\Repositories\Frontend\CMSPages;
use App\Exceptions\GeneralException;
use App\Models\CMSPages\CMSPage;
use App\Repositories\BaseRepository;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
/**
* Class CMSPagesRepository.
......
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