Unverified Commit 7097767f authored by Viral Solani's avatar Viral Solani Committed by GitHub

Merge pull request #120 from bvipul/develop

Page and Settings Test Cases
parents 130e2c18 86e27311
......@@ -57,7 +57,7 @@ class BlogCategoriesController extends Controller
$this->blogcategory->create($request->all());
return redirect()
->route('admin.blogcategories.index')
->route('admin.blogCategories.index')
->with('flash_success', trans('alerts.backend.blogcategories.created'));
}
......@@ -67,10 +67,10 @@ class BlogCategoriesController extends Controller
*
* @return mixed
*/
public function edit(BlogCategory $blogcategory, EditBlogCategoriesRequest $request)
public function edit(BlogCategory $blogCategory, EditBlogCategoriesRequest $request)
{
return view('backend.blogcategories.edit')
->with('blogcategory', $blogcategory);
->with('blogcategory', $blogCategory);
}
/**
......@@ -79,12 +79,12 @@ class BlogCategoriesController extends Controller
*
* @return mixed
*/
public function update(BlogCategory $blogcategory, UpdateBlogCategoriesRequest $request)
public function update(BlogCategory $blogCategory, UpdateBlogCategoriesRequest $request)
{
$this->blogcategory->update($blogcategory, $request->all());
$this->blogcategory->update($blogCategory, $request->all());
return redirect()
->route('admin.blogcategories.index')
->route('admin.blogCategories.index')
->with('flash_success', trans('alerts.backend.blogcategories.updated'));
}
......@@ -94,12 +94,12 @@ class BlogCategoriesController extends Controller
*
* @return mixed
*/
public function destroy(BlogCategory $blogcategory, DeleteBlogCategoriesRequest $request)
public function destroy(BlogCategory $blogCategory, DeleteBlogCategoriesRequest $request)
{
$this->blogcategory->delete($blogcategory);
$this->blogcategory->delete($blogCategory);
return redirect()
->route('admin.blogcategories.index')
->route('admin.blogCategories.index')
->with('flash_success', trans('alerts.backend.blogcategories.deleted'));
}
}
......@@ -32,17 +32,17 @@ class PagesTableController extends Controller
{
return Datatables::of($this->pages->getForDataTable())
->escapeColumns(['title'])
->addColumn('status', function ($pages) {
return $pages->status_label;
->addColumn('status', function ($page) {
return $page->status_label;
})
->addColumn('created_at', function ($pages) {
return Carbon::parse($pages->created_at)->toDateString();
->addColumn('created_at', function ($page) {
return $page->created_at->toDateString();
})
->addColumn('updated_at', function ($pages) {
return Carbon::parse($pages->updated_at)->toDateString();
->addColumn('created_by', function ($page) {
return $page->created_by;
})
->addColumn('actions', function ($pages) {
return $pages->action_buttons;
->addColumn('actions', function ($page) {
return $page->action_buttons;
})
->make(true);
}
......
......@@ -45,27 +45,9 @@ class SettingsController extends Controller
public function update(Setting $setting, UpdateSettingsRequest $request)
{
$this->settings->update($setting, $request->except(['_token', '_method']));
return redirect()
->route('admin.settings.edit', $setting->id)
->with('flash_success', trans('alerts.backend.settings.updated'));
}
/**
* @param Setting $setting
* @param Request $request
* Remove logo or favicon icon
*
* @return mixed
*/
public function removeIcon(Request $request)
{
$this->settings->removeicon($request->data);
return json_encode(
[
'status' => true,
]
);
}
}
<?php
namespace App\Http\Controllers\Backend\Settings;
use App\Http\Controllers\Controller;
use App\Models\Settings\Setting;
use App\Repositories\Backend\Settings\SettingsRepository;
use Illuminate\Http\Request;
/**
* Class SettingsLogoController.
*/
class SettingsLogoController extends Controller
{
protected $settings;
/**
* @param \App\Repositories\Backend\Settings\SettingsRepository $settings
*/
public function __construct(SettingsRepository $settings)
{
$this->settings = $settings;
}
/**
* Remove logo or favicon icon
*
* @param \App\Models\Settings\Setting $setting
* @param \Illuminate\Http\Request $request
*
* @return mixed
*/
public function destroy(Setting $setting, Request $request)
{
$this->settings->removeLogo($setting, $request->data);
return json_encode([
'status' => true
]);
}
}
......@@ -4,13 +4,15 @@ namespace App\Models\Page;
use App\Models\BaseModel;
use App\Models\ModelTrait;
use App\Models\Page\Traits\Attribute\PageAttribute;
use App\Models\Page\Traits\PageRelationship;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Models\Page\Traits\Attribute\PageAttribute;
class Page extends BaseModel
{
use ModelTrait,
SoftDeletes,
PageRelationship,
PageAttribute {
// PageAttribute::getEditButtonAttribute insteadof ModelTrait;
}
......@@ -29,6 +31,17 @@ class Page extends BaseModel
*/
protected $guarded = ['id'];
/**
* The default values for attributes
*
* @var array
*/
protected $attributes = [
'created_by' => 1
];
protected $with = ['owner'];
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
......
......@@ -13,8 +13,8 @@ trait PageAttribute
public function getActionButtonsAttribute()
{
return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute('edit-cms-pages', 'admin.pages.edit').'
'.$this->getDeleteButtonAttribute('delete-cms-pages', 'admin.pages.destroy').'
'.$this->getEditButtonAttribute('edit-page', 'admin.pages.edit').'
'.$this->getDeleteButtonAttribute('delete-page', 'admin.pages.destroy').'
</div>';
}
......
<?php
namespace App\Models\Page\Traits;
use App\Models\Access\User\User;
trait PageRelationship
{
public function owner()
{
return $this->belongsTo(User::class, 'created_by');
}
}
\ No newline at end of file
......@@ -132,7 +132,7 @@ class BlogsRepository extends BaseRepository
/**
* Creating Tags.
*
* @param Array($tags)
* @param Array $tags
*
* @return array
*/
......
......@@ -224,9 +224,15 @@ class EloquentHistoryRepository implements HistoryContract
{
$assets = json_decode($assets, true);
$count = 1;
$asset_count = count($assets) + 1;
$asset_count = 1;
$flag = false;
if (count($assets)) {
if (is_array($assets) || $assets instanceof \Countable) {
$asset_count = count($assets) + 1;
$flag = true;
}
if ($flag) {
foreach ($assets as $name => $values) {
$key = explode('_', $name)[0];
$type = explode('_', $name)[1];
......
......@@ -25,12 +25,14 @@ class PagesRepository extends BaseRepository
public function getForDataTable()
{
return $this->query()
->leftjoin(config('access.users_table'), config('access.users_table').'.id', '=', config('module.pages.table').'.created_by')
->select([
config('module.pages.table').'.id',
config('module.pages.table').'.title',
config('module.pages.table').'.status',
config('module.pages.table').'.created_at',
config('module.pages.table').'.updated_at',
config('access.users_table').'.first_name as created_by'
]);
}
......@@ -47,7 +49,7 @@ class PagesRepository extends BaseRepository
throw new GeneralException(trans('exceptions.backend.pages.already_exists'));
}
//Making extra fields
// Making extra fields
$input['page_slug'] = str_slug($input['title']);
$input['status'] = isset($input['status']) ? 1 : 0;
$input['created_by'] = auth()->id();
......@@ -75,7 +77,7 @@ class PagesRepository extends BaseRepository
throw new GeneralException(trans('exceptions.backend.pages.already_exists'));
}
//Making extra fields
// Making extra fields
$input['page_slug'] = str_slug($input['title']);
$input['status'] = isset($input['status']) ? 1 : 0;
$input['updated_by'] = access()->user()->id;
......
......@@ -2,9 +2,10 @@
namespace App\Repositories\Backend\Settings;
use App\Exceptions\GeneralException;
use App\Models\Settings\Setting;
use App\Exceptions\GeneralException;
use App\Repositories\BaseRepository;
use Illuminate\Support\Facades\Storage;
/**
* Class SettingsRepository.
......@@ -16,29 +17,61 @@ class SettingsRepository extends BaseRepository
*/
const MODEL = Setting::class;
/**
* Site Logo Path
*
* @var string
*/
protected $site_logo_path;
/**
* Favicon path
*
* @var string
*/
protected $favicon_path;
/**
* Storage Class Object
*
* @var \Illuminate\Support\Facades\Storage
*/
protected $storage;
/**
* Constructor
*/
public function __construct()
{
$this->site_logo_path = 'img'. DIRECTORY_SEPARATOR . 'logo' . DIRECTORY_SEPARATOR;
$this->favicon_path = 'img' . DIRECTORY_SEPARATOR . 'favicon' . DIRECTORY_SEPARATOR;
$this->storage = Storage::disk('public');
}
/**
* @param \App\Models\Settings\Setting $setting
* @param $input
* @param Array $input
*
* @throws \App\Exceptions\GeneralException
*
* return bool
* @return bool
*/
public function update(Setting $setting, array $input)
{
if (isset($input['logo'])) {
$image_upload = $this->uploadlogoimage($setting, $input['logo']);
$input['logo'] = $image_upload;
if (! empty($input['logo'])) {
$this->removeLogo($setting, 'logo');
$input['logo'] = $this->uploadLogo($setting, $input['logo'], 'logo');
}
if (isset($input['favicon'])) {
$image_upload = $this->uploadfaviconimage($setting, $input['favicon']);
$input['favicon'] = $image_upload;
if (! empty($input['favicon'])) {
$this->removeLogo($setting, 'favicon');
$input['favicon'] = $this->uploadLogo($setting, $input['favicon'], 'favicon');
}
if ($setting->update($input)) {
if ($setting->update($input))
return true;
}
throw new GeneralException(trans('exceptions.backend.settings.update_error'));
}
......@@ -46,63 +79,32 @@ class SettingsRepository extends BaseRepository
/*
* Upload logo image
*/
public function uploadlogoimage($setting, $logo)
public function uploadLogo($setting, $logo, $type)
{
$image_name_ex = $logo->getClientOriginalExtension();
$path = $type == "logo" ? $this->site_logo_path : $this->favicon_path;
if ($setting->logo) {
if (file_exists(public_path().'/img/site_logo/'.$setting->logo)) {
unlink('img/site_logo/'.$setting->logo);
}
}
$image_name = time() . $logo->getClientOriginalName();
$image_name = time().$logo->getClientOriginalName();
$destinationPath = public_path('img/site_logo');
$logo->move($destinationPath, $image_name);
$this->storage->put($path . $image_name, file_get_contents($logo->getRealPath()));
return $image_name;
}
/*
* Upload favicon icon image
* remove logo or favicon icon
*/
public function uploadfaviconimage($setting, $logo)
public function removeLogo(Setting $setting, $type)
{
$image_name_ex = $logo->getClientOriginalExtension();
$path = $type == "logo" ? $this->site_logo_path : $this->favicon_path;
if ($setting->favicon) {
if (file_exists(public_path().'/img/favicon_icon/'.$setting->favicon)) {
unlink('img/favicon_icon/'.$setting->favicon);
}
if ($setting->$type && $this->storage->exists($path . $setting->$type)) {
$this->storage->delete($path . $setting->$type);
}
$image_name = time().$logo->getClientOriginalName();
$destinationPath = public_path('/img/favicon_icon');
$logo->move($destinationPath, $image_name);
$result = $setting->update([ $type => null ]);
return $image_name;
}
if($result) return true;
/*
* remove logo or favicon icon
*/
public function removeicon($input)
{
$setting = $this->query()->get();
if ($input == 'logo') {
if ($setting[0]->logo) {
if (file_exists(public_path().'/img/site_logo/'.$setting[0]->logo)) {
unlink('img/site_logo/'.$setting[0]->logo);
}
$this->query()->update(['logo' => null]);
}
} else {
if ($setting[0]->favicon) {
if (file_exists(public_path().'/img/favicon_icon/'.$setting[0]->favicon)) {
unlink('img/favicon_icon/'.$setting[0]->favicon);
}
}
$this->query()->update(['favicon' => null]);
}
throw new GeneralException(trans('exceptions.backend.settings.update_error'));
}
}
<?php
use Faker\Generator as Faker;
use App\Models\Access\User\User;
use App\Models\BlogCategories\BlogCategory;
$factory->define(BlogCategory::class, function (Faker $faker) {
return [
'name' => $faker->word,
'status' => $faker->numberBetween(0, 1),
'created_by' => function () {
return factory(User::class)->create()->id;
},
];
});
......@@ -16,7 +16,7 @@ class CreateBlogCategoriesTable extends Migration
$table->increments('id');
$table->string('name', 191);
$table->boolean('status')->default(1);
$table->integer('created_by')->unsigned();
$table->integer('created_by')->unsigned()->nullable();
$table->integer('updated_by')->unsigned()->nullable();
$table->timestamps();
$table->softDeletes();
......
......@@ -18,7 +18,7 @@ class MenuTableSeeder extends Seeder
'id' => 1,
'type' => 'backend',
'name' => 'Backend Sidebar Menu',
'items' => '[{"view_permission_id":"view-access-management","icon":"fa-users","open_in_new_tab":0,"url_type":"route","url":"","name":"Access Management","id":11,"content":"Access Management","children":[{"view_permission_id":"view-user-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.user.index","name":"User Management","id":12,"content":"User Management"},{"view_permission_id":"view-role-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.role.index","name":"Role Management","id":13,"content":"Role Management"},{"view_permission_id":"view-permission-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.permission.index","name":"Permission Management","id":14,"content":"Permission Management"}]},{"view_permission_id":"view-module","icon":"fa-wrench","open_in_new_tab":0,"url_type":"route","url":"admin.modules.index","name":"Module","id":1,"content":"Module"},{"view_permission_id":"view-menu","icon":"fa-bars","open_in_new_tab":0,"url_type":"route","url":"admin.menus.index","name":"Menus","id":3,"content":"Menus"},{"view_permission_id":"view-page","icon":"fa-file-text","open_in_new_tab":0,"url_type":"route","url":"admin.pages.index","name":"Pages","id":2,"content":"Pages"},{"view_permission_id":"view-email-template","icon":"fa-envelope","open_in_new_tab":0,"url_type":"route","url":"admin.emailtemplates.index","name":"Email Templates","id":8,"content":"Email Templates"},{"view_permission_id":"edit-settings","icon":"fa-gear","open_in_new_tab":0,"url_type":"route","url":"admin.settings.edit?id=1","name":"Settings","id":9,"content":"Settings"},{"view_permission_id":"view-blog","icon":"fa-commenting","open_in_new_tab":0,"url_type":"route","url":"","name":"Blog Management","id":15,"content":"Blog Management","children":[{"view_permission_id":"view-blog-category","open_in_new_tab":0,"url_type":"route","url":"admin.blogcategories.index","name":"Blog Category Management","id":16,"content":"Blog Category Management"},{"view_permission_id":"view-blog-tag","open_in_new_tab":0,"url_type":"route","url":"admin.blogtags.index","name":"Blog Tag Management","id":17,"content":"Blog Tag Management"},{"view_permission_id":"view-blog","open_in_new_tab":0,"url_type":"route","url":"admin.blogs.index","name":"Blog Management","id":18,"content":"Blog Management"}]},{"view_permission_id":"view-faq","icon":"fa-question-circle","open_in_new_tab":0,"url_type":"route","url":"admin.faqs.index","name":"Faq Management","id":19,"content":"Faq Management"}]',
'items' => '[{"view_permission_id":"view-access-management","icon":"fa-users","open_in_new_tab":0,"url_type":"route","url":"","name":"Access Management","id":11,"content":"Access Management","children":[{"view_permission_id":"view-user-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.user.index","name":"User Management","id":12,"content":"User Management"},{"view_permission_id":"view-role-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.role.index","name":"Role Management","id":13,"content":"Role Management"},{"view_permission_id":"view-permission-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.permission.index","name":"Permission Management","id":14,"content":"Permission Management"}]},{"view_permission_id":"view-module","icon":"fa-wrench","open_in_new_tab":0,"url_type":"route","url":"admin.modules.index","name":"Module","id":1,"content":"Module"},{"view_permission_id":"view-menu","icon":"fa-bars","open_in_new_tab":0,"url_type":"route","url":"admin.menus.index","name":"Menus","id":3,"content":"Menus"},{"view_permission_id":"view-page","icon":"fa-file-text","open_in_new_tab":0,"url_type":"route","url":"admin.pages.index","name":"Pages","id":2,"content":"Pages"},{"view_permission_id":"view-email-template","icon":"fa-envelope","open_in_new_tab":0,"url_type":"route","url":"admin.emailtemplates.index","name":"Email Templates","id":8,"content":"Email Templates"},{"view_permission_id":"edit-settings","icon":"fa-gear","open_in_new_tab":0,"url_type":"route","url":"admin.settings.edit?id=1","name":"Settings","id":9,"content":"Settings"},{"view_permission_id":"view-blog","icon":"fa-commenting","open_in_new_tab":0,"url_type":"route","url":"","name":"Blog Management","id":15,"content":"Blog Management","children":[{"view_permission_id":"view-blog-category","open_in_new_tab":0,"url_type":"route","url":"admin.blogCategories.index","name":"Blog Category Management","id":16,"content":"Blog Category Management"},{"view_permission_id":"view-blog-tag","open_in_new_tab":0,"url_type":"route","url":"admin.blogtags.index","name":"Blog Tag Management","id":17,"content":"Blog Tag Management"},{"view_permission_id":"view-blog","open_in_new_tab":0,"url_type":"route","url":"admin.blogs.index","name":"Blog Management","id":18,"content":"Blog Management"}]},{"view_permission_id":"view-faq","icon":"fa-question-circle","open_in_new_tab":0,"url_type":"route","url":"admin.faqs.index","name":"Faq Management","id":19,"content":"Faq Management"}]',
'created_by' => 1,
'created_at' => Carbon::now(),
];
......
{
"/js/frontend.js": "/js/frontend.945469bbbc12df3ad9e1.js",
"/js/backend.js": "/js/backend.79d9e4698dadbc0d93c7.js",
"/mix.js": "/mix.247ab120fe7680658924.js",
"/css/frontend.css": "/css/frontend.3af0a6cbd7d1d8d042f2a37e97008b7c.css",
"/css/backend.css": "/css/backend.f8550f50504e5b8ef6055285205f223a.css",
"/css/backend-custom.css": "/css/backend-custom.18e74fbe4c755b817a022d6d3d4e76b1.css",
"/js/backend-custom.js": "/js/backend-custom.e6ea05e1824d0dd8e7c62027c135b7f2.js",
"/js/dataTable.js": "/js/dataTable.f968d300a6a0b871f138f114361259c8.js"
}
\ No newline at end of file
......@@ -126,6 +126,7 @@ return [
'status' => 'Status',
'createdat' => 'Created At',
'updatedat' => 'Updated At',
'createdby' => 'Created By',
'all' => 'All',
],
],
......@@ -200,7 +201,7 @@ return [
'companydetails' => 'Company Contact Details',
'mail' => 'Mail Settings',
'footer' => 'Footer Settings',
'terms' => 'Terms & Condition Settings',
'terms' => 'Terms and Condition Settings',
'google' => 'Google Analytics Track Code',
],
......
......@@ -70,7 +70,7 @@
processing: true,
serverSide: true,
ajax: {
url: '{{ route("admin.blogcategories.get") }}',
url: '{{ route("admin.blogCategories.get") }}',
type: 'post'
},
columns: [
......
<!--Action Button-->
@if(Active::checkUriPattern('admin/blogcategories'))
@if(Active::checkUriPattern('admin/blogCategories'))
<div class="btn-group">
<button type="button" class="btn btn-warning btn-flat dropdown-toggle" data-toggle="dropdown">Export
<span class="caret"></span>
......@@ -21,9 +21,9 @@
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="{{route('admin.blogcategories.index')}}"><i class="fa fa-list-ul"></i> {{trans('menus.backend.blogcategories.all')}}</a></li>
<li><a href="{{route('admin.blogCategories.index')}}"><i class="fa fa-list-ul"></i> {{trans('menus.backend.blogcategories.all')}}</a></li>
@permission('create-blog-category')
<li><a href="{{route('admin.blogcategories.create')}}"><i class="fa fa-plus"></i> {{trans('menus.backend.blogcategories.create')}}</a></li>
<li><a href="{{route('admin.blogCategories.create')}}"><i class="fa fa-plus"></i> {{trans('menus.backend.blogcategories.create')}}</a></li>
@endauth
</ul>
</div>
\ No newline at end of file
......@@ -24,7 +24,7 @@
<th>{{ trans('labels.backend.pages.table.title') }}</th>
<th>{{ trans('labels.backend.pages.table.status') }}</th>
<th>{{ trans('labels.backend.pages.table.createdat') }}</th>
<th>{{ trans('labels.backend.pages.table.updatedat') }}</th>
<th>{{ trans('labels.backend.pages.table.createdby') }}</th>
<th>{{ trans('labels.general.actions') }}</th>
</tr>
</thead>
......@@ -77,10 +77,10 @@
{data: 'title', name: '{{config('module.pages.table')}}.title'},
{data: 'status', name: '{{config('module.pages.table')}}.status'},
{data: 'created_at', name: '{{config('module.pages.table')}}.created_at'},
{data: 'updated_at', name: '{{config('module.pages.table')}}.updated_at'},
{data: 'created_by', name: '{{config('access.users_table')}}.first_name'},
{data: 'actions', name: 'actions', searchable: false, sortable: false}
],
order: [[3, "asc"]],
order: [[1, "asc"]],
searchDelay: 500,
dom: 'lBfrtip',
buttons: {
......
@extends ('backend.layouts.app')
@extends ('backend.layouts.app')
@section ('title', trans('labels.backend.settings.management') . ' | ' . trans('labels.backend.settings.edit'))
@section('page-header')
<h1>
{{ trans('labels.backend.settings.management') }}
<small>{{ trans('labels.backend.settings.edit') }}</small>
</h1>
@endsection
@section('content')
{{ Form::model($setting, ['route' => ['admin.settings.update', $setting], 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'PATCH','files' => true, 'id' => 'edit-role']) }}
<div class="box box-info">
<div class="box-header">
<h3 class="box-title">{{ trans('labels.backend.settings.edit') }}</h3>
</div><!-- /.box-header -->
<div class="box-body setting-block">
<!-- Nav tabs -->
<ul id="myTab" class="nav nav-tabs setting-tab-list" role="tablist">
<li role="presentation" class="active"><a href="#tab1" aria-controls="home" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.seo') }}</a></li>
<li role="presentation"><a href="#tab2" aria-controls="1" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.companydetails') }}</a></li>
<li role="presentation"><a href="#tab3" aria-controls="2" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.mail') }}</a></li>
<li role="presentation"><a href="#tab4" aria-controls="3" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.footer') }}</a></li>
<li role="presentation"><a href="#tab5" aria-controls="4" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.terms') }}</a></li>
<li role="presentation"><a href="#tab6" aria-controls="5" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.google') }}</a></li>
</ul>
<!-- Tab panes -->
<div id="myTabContent" class="tab-content setting-tab">
<div role="tabpanel" class="tab-pane active" id="tab1">
<div class="form-group">
{{ Form::label('logo', trans('validation.attributes.backend.settings.sitelogo'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
<div class="custom-file-input">
{!! Form::file('logo', array('class'=>'form-control inputfile inputfile-1' )) !!}
<label for="logo"><i class="fa fa-upload"></i><span>Choose a file</span></label>
</div>
<div class="img-remove-logo">
@if($setting->logo)
<img height="50" width="50" src="{{url('/img/site_logo/')}}/{{$setting->logo}}">
<i id="remove-logo-img" class="fa fa-times remove-logo" data-id="logo" aria-hidden="true"></i>
@endif
</div>
</div><!--col-lg-10-->
</div><!--form control-->
<div class="form-group">
{{ Form::label('favicon', trans('validation.attributes.backend.settings.favicon'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
<div class="custom-file-input">
{!! Form::file('favicon', array('class'=>'form-control inputfile inputfile-1' )) !!}
<label for="favicon"><i class="fa fa-upload"></i><span>Choose a file</span></label>
</div>
<div class="img-remove-favicon">
@if($setting->favicon)
<img height="50" width="50" src="{{url('/img/favicon_icon/')}}/{{$setting->favicon}}">
<i id="remove-favicon-img" class="fa fa-times remove-logo" data-id="favicon" aria-hidden="true"></i>
@endif
</div>
</div><!--col-lg-10-->
</div><!--form control-->
<div class="form-group">
{{ Form::label('seo_title', trans('validation.attributes.backend.settings.metatitle'), ['class' => 'col-lg-2 control-label']) }}
<div class="col-lg-10">
{{ Form::text('seo_title', null, ['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.metatitle')]) }}
</div><!--col-lg-10-->
</div><!--form control-->
<div class="form-group">
{{ Form::label('seo_keyword', trans('validation.attributes.backend.settings.metakeyword'), ['class' => 'col-lg-2 control-label']) }}
<div class="col-lg-10">
{{ Form::textarea('seo_keyword', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.metakeyword'), 'rows' => 2]) }}
</div><!--col-lg-3-->
</div><!--form control-->
<div class="form-group">
{{ Form::label('seo_description', trans('validation.attributes.backend.settings.metadescription'), ['class' => 'col-lg-2 control-label']) }}
<div class="col-lg-10">
{{ Form::textarea('seo_description', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.metadescription'), 'rows' => 2]) }}
</div><!--col-lg-3-->
</div><!--form control-->
</div>
<div role="tabpanel" class="tab-pane" id="tab2">
<div class="form-group">
{{ Form::label('company_address', trans('validation.attributes.backend.settings.companydetails.address'), ['class' => 'col-lg-2 control-label']) }}
<div class="col-lg-10">
{{ Form::textarea('company_address', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.companydetails.address'), 'rows' => 2]) }}
</div>
</div>
<div class="form-group">
{{ Form::label('company_contact', trans('validation.attributes.backend.settings.companydetails.contactnumber'), ['class' => 'col-lg-2 control-label']) }}
<div class="col-lg-10">
{{ Form::text('company_contact', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.companydetails.contactnumber'), 'rows' => 2]) }}
</div>
</div><!--form control-->
</div>
<div role="tabpanel" class="tab-pane" id="tab3">
<div class="form-group">
{{ Form::label('from_name', trans('validation.attributes.backend.settings.mail.fromname'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
{{ Form::text('from_name', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.mail.fromname'), 'rows' => 2]) }}
</div>
</div>
<div class="form-group">
{{ Form::label('from_email', trans('validation.attributes.backend.settings.mail.fromemail'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
{{ Form::text('from_email', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.mail.fromemail'), 'rows' => 2]) }}
</div>
</div><!--form control-->
</div>
<div role="tabpanel" class="tab-pane" id="tab4">
<div class="form-group">
{{ Form::label('footer_text', trans('validation.attributes.backend.settings.footer.text'), ['class' => 'col-lg-2 control-label']) }}
<div class="col-lg-10">
{{ Form::text('footer_text', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.footer.text'), 'rows' => 2]) }}
</div>
</div>
<div class="form-group">
{{ Form::label('copyright_text', trans('validation.attributes.backend.settings.footer.copyright'), ['class' => 'col-lg-2 control-label']) }}
<div class="col-lg-10">
{{ Form::text('copyright_text', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.footer.copyright'), 'rows' => 2]) }}
</div>
</div><!--form control-->
</div>
<div role="tabpanel" class="tab-pane" id="tab5">
<div class="form-group">
{{ Form::label('terms', trans('validation.attributes.backend.settings.termscondition.terms'), ['class' => 'col-lg-2 control-label']) }}
<div class="col-lg-10">
{{ Form::textarea('terms', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.termscondition.terms')]) }}
</div>
</div>
<div class="form-group">
{{ Form::label('disclaimer', trans('validation.attributes.backend.settings.termscondition.disclaimer'), ['class' => 'col-lg-2 control-label']) }}
<div class="col-lg-10">
{{ Form::textarea('disclaimer', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.termscondition.disclaimer')]) }}
</div>
</div><!--form control-->
</div>
<div role="tabpanel" class="tab-pane" id="tab6">
<div class="form-group">
{{ Form::label('google_analytics', trans('validation.attributes.backend.settings.google.analytic'), ['class' => 'col-lg-2 control-label']) }}
<div class="col-lg-10">
{{ Form::textarea('google_analytics', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.google.analytic')]) }}
</div>
</div><!--form control-->
</div>
</div>
</div><!-- /.box-body -->
<div class="box-footer">
<div class="row">
<div class="col-lg-offset-2 col-lg-10 footer-btn">
{{ Form::submit(trans('buttons.general.crud.update'), ['class' => 'btn btn-primary btn-md']) }}
<div class="clearfix"></div>
</div>
</div>
</div>
</div><!--box-->
{{ Form::close() }}
@endsection
<h1>
{{ trans('labels.backend.settings.management') }}
<small>{{ trans('labels.backend.settings.edit') }}</small>
</h1>
@endsection
@section('content')
{{ Form::model($setting, ['route' => ['admin.settings.update', $setting], 'class' => 'form-horizontal',
'role' => 'form', 'method' => 'PATCH','files' => true, 'id' => 'edit-settings']) }}
<div class="box box-info">
<div class="box-header">
<h3 class="box-title">{{ trans('labels.backend.settings.edit') }}</h3>
</div>
<!-- /.box-header -->
<div class="box-body setting-block">
<!-- Nav tabs -->
<ul id="myTab" class="nav nav-tabs setting-tab-list" role="tablist">
<li role="presentation" class="active">
<a href="#tab1" aria-controls="home" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.seo') }}</a>
</li>
<li role="presentation">
<a href="#tab2" aria-controls="1" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.companydetails') }}</a>
</li>
<li role="presentation">
<a href="#tab3" aria-controls="2" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.mail') }}</a>
</li>
<li role="presentation">
<a href="#tab4" aria-controls="3" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.footer') }}</a>
</li>
<li role="presentation">
<a href="#tab5" aria-controls="4" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.terms') }}</a>
</li>
<li role="presentation">
<a href="#tab6" aria-controls="5" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.google') }}</a>
</li>
</ul>
<!-- Tab panes -->
<div id="myTabContent" class="tab-content setting-tab">
<div role="tabpanel" class="tab-pane active" id="tab1">
<div class="form-group">
{{ Form::label('logo', trans('validation.attributes.backend.settings.sitelogo'), ['class' => 'col-lg-2 control-label']) }}
<div class="col-lg-10">
<div class="custom-file-input">
{!! Form::file('logo', array('class'=>'form-control inputfile inputfile-1' )) !!}
<label for="logo">
<i class="fa fa-upload"></i>
<span>Choose a file</span>
</label>
</div>
<div class="img-remove-logo">
@if($setting->logo)
<img height="50" width="50" src="{{ Storage::disk('public')->url('img/site_logo/' . $setting->logo) }}">
<i id="remove-logo-img" class="fa fa-times remove-logo" data-id="logo" aria-hidden="true"></i>
@endif
</div>
</div>
<!--col-lg-10-->
</div>
<!--form control-->
<div class="form-group">
{{ Form::label('favicon', trans('validation.attributes.backend.settings.favicon'), ['class' => 'col-lg-2 control-label'])
}}
<div class="col-lg-10">
<div class="custom-file-input">
{!! Form::file('favicon', array('class'=>'form-control inputfile inputfile-1' )) !!}
<label for="favicon">
<i class="fa fa-upload"></i>
<span>Choose a file</span>
</label>
</div>
<div class="img-remove-favicon">
@if($setting->favicon)
<img height="50" width="50" src="{{ Storage::disk('public')->url('img/favicon/' . $setting->favicon) }}">
<i id="remove-favicon-img" class="fa fa-times remove-logo" data-id="favicon" aria-hidden="true"></i>
@endif
</div>
</div>
<!--col-lg-10-->
</div>
<!--form control-->
<div class="form-group">
{{ Form::label('seo_title', trans('validation.attributes.backend.settings.metatitle'), ['class' => 'col-lg-2 control-label'])
}}
<div class="col-lg-10">
{{ Form::text('seo_title', null, ['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.metatitle')])
}}
</div>
<!--col-lg-10-->
</div>
<!--form control-->
<div class="form-group">
{{ Form::label('seo_keyword', trans('validation.attributes.backend.settings.metakeyword'), ['class' => 'col-lg-2 control-label'])
}}
<div class="col-lg-10">
{{ Form::textarea('seo_keyword', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.metakeyword'),
'rows' => 2]) }}
</div>
<!--col-lg-3-->
</div>
<!--form control-->
<div class="form-group">
{{ Form::label('seo_description', trans('validation.attributes.backend.settings.metadescription'), ['class' => 'col-lg-2
control-label']) }}
<div class="col-lg-10">
{{ Form::textarea('seo_description', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.metadescription'),
'rows' => 2]) }}
</div>
<!--col-lg-3-->
</div>
<!--form control-->
</div>
<div role="tabpanel" class="tab-pane" id="tab2">
<div class="form-group">
{{ Form::label('company_address', trans('validation.attributes.backend.settings.companydetails.address'), ['class' => 'col-lg-2
control-label']) }}
<div class="col-lg-10">
{{ Form::textarea('company_address', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.companydetails.address'),
'rows' => 2]) }}
</div>
</div>
<div class="form-group">
{{ Form::label('company_contact', trans('validation.attributes.backend.settings.companydetails.contactnumber'), ['class'
=> 'col-lg-2 control-label']) }}
<div class="col-lg-10">
{{ Form::text('company_contact', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.companydetails.contactnumber'),
'rows' => 2]) }}
</div>
</div>
<!--form control-->
</div>
<div role="tabpanel" class="tab-pane" id="tab3">
<div class="form-group">
{{ Form::label('from_name', trans('validation.attributes.backend.settings.mail.fromname'), ['class' => 'col-lg-2 control-label'])
}}
<div class="col-lg-10">
{{ Form::text('from_name', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.mail.fromname'),
'rows' => 2]) }}
</div>
</div>
<div class="form-group">
{{ Form::label('from_email', trans('validation.attributes.backend.settings.mail.fromemail'), ['class' => 'col-lg-2 control-label'])
}}
<div class="col-lg-10">
{{ Form::text('from_email', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.mail.fromemail'),
'rows' => 2]) }}
</div>
</div>
<!--form control-->
</div>
<div role="tabpanel" class="tab-pane" id="tab4">
<div class="form-group">
{{ Form::label('footer_text', trans('validation.attributes.backend.settings.footer.text'), ['class' => 'col-lg-2 control-label'])
}}
<div class="col-lg-10">
{{ Form::text('footer_text', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.footer.text'),
'rows' => 2]) }}
</div>
</div>
<div class="form-group">
{{ Form::label('copyright_text', trans('validation.attributes.backend.settings.footer.copyright'), ['class' => 'col-lg-2
control-label']) }}
<div class="col-lg-10">
{{ Form::text('copyright_text', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.footer.copyright'),
'rows' => 2]) }}
</div>
</div>
<!--form control-->
</div>
<div role="tabpanel" class="tab-pane" id="tab5">
<div class="form-group">
{{ Form::label('terms', trans('validation.attributes.backend.settings.termscondition.terms'), ['class' => 'col-lg-2 control-label'])
}}
<div class="col-lg-10">
{{ Form::textarea('terms', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.termscondition.terms')])
}}
</div>
</div>
<div class="form-group">
{{ Form::label('disclaimer', trans('validation.attributes.backend.settings.termscondition.disclaimer'), ['class' => 'col-lg-2
control-label']) }}
<div class="col-lg-10">
{{ Form::textarea('disclaimer', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.termscondition.disclaimer')])
}}
</div>
</div>
<!--form control-->
</div>
<div role="tabpanel" class="tab-pane" id="tab6">
<div class="form-group">
{{ Form::label('google_analytics', trans('validation.attributes.backend.settings.google.analytic'), ['class' => 'col-lg-2
control-label']) }}
<div class="col-lg-10">
{{ Form::textarea('google_analytics', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.google.analytic')])
}}
</div>
</div>
<!--form control-->
</div>
</div>
</div>
<!-- /.box-body -->
<div class="box-footer">
<div class="row">
<div class="col-lg-offset-2 col-lg-10 footer-btn">
{{ Form::submit(trans('buttons.general.crud.update'), ['class' => 'btn btn-primary btn-md']) }}
<div class="clearfix"></div>
</div>
</div>
</div>
</div><!--box-->
<!-- hidden setting id variable -->
<input type="hidden" data-id="{{ $setting->id }}" id="setting">
{{ Form::close() }}
@endsection
@section('after-scripts')
<script src='/js/backend/bootstrap-tabcollapse.js'></script>
<script>
$('.remove-logo').click(function(){
var data_id = $(this).data('id');
var route = "{{ route('admin.removeIcon', -1) }}";
var data_id = $('#setting').data('id');
route = route.replace('-1', data_id);
$('.remove-logo').click(function() {
var data = $(this).data('id');
swal({
title: "Warning",
text: "Are you sure you want to remove?",
......@@ -191,7 +262,7 @@
}, function (confirmed) {
if (confirmed)
{
var data = data_id;
console.log(data);
if(data=='logo')
{
value= 'logo';
......@@ -203,7 +274,7 @@
$('.img-remove-favicon').addClass('hidden');
}
$.ajax({
url: "{{route('admin.removeicon')}}",
url: route,
type: "POST",
data: {data: value},
});
......@@ -215,5 +286,6 @@
tabsClass: 'hidden-sm hidden-xs',
accordionClass: 'visible-sm visible-xs'
});
</script>
@endsection
\ No newline at end of file
......@@ -4,9 +4,9 @@
* Blogs Categories Management
*/
Route::group(['namespace' => 'BlogCategories'], function () {
Route::resource('blogcategories', 'BlogCategoriesController', ['except' => ['show']]);
Route::resource('blogCategories', 'BlogCategoriesController', ['except' => ['show']]);
//For DataTables
Route::post('blogcategories/get', 'BlogCategoriesTableController')
->name('blogcategories.get');
Route::post('blogCategories/get', 'BlogCategoriesTableController')
->name('blogCategories.get');
});
......@@ -6,5 +6,5 @@
Route::group(['namespace' => 'Settings'], function () {
Route::resource('settings', 'SettingsController', ['except' => ['show', 'create', 'save', 'index', 'destroy']]);
Route::post('removeicon', 'SettingsController@removeIcon')->name('removeicon');
Route::post('removeicon/{setting}', 'SettingsLogoController@destroy')->name('removeIcon');
});
<?php
namespace Tests\Feature\Backend;
use Tests\TestCase;
use App\Models\Settings\Setting;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ManageSettingsTest extends TestCase
{
protected $setting;
public function setUp()
{
parent::setUp();
$this->setting = Setting::find(1);
$this->actingAs($this->admin);
}
/** @test */
public function setting_page_shows_different_tabs()
{
$this->get(route('admin.settings.edit', $this->setting))
->assertSee(__('labels.backend.settings.seo'))
->assertSee(__('labels.backend.settings.companydetails'))
->assertSee(__('labels.backend.settings.mail'))
->assertSee(__('labels.backend.settings.footer'))
->assertSee(__('labels.backend.settings.terms'))
->assertSee(__('labels.backend.settings.google'));
}
/** @test */
public function it_can_update_a_valid_site_logo()
{
$this->patch(route('admin.settings.update', $this->setting), [
'logo' => UploadedFile::fake()->image('logo.jpg', 226, 48)
]);
Storage::disk('public')->assertExists('img/logo/' . $this->setting->logo);
}
/** @test */
public function it_throws_error_for_valid_site_logo()
{
$this->withExceptionHandling();
$this->patch(route('admin.settings.update', $this->setting), [
'logo' => UploadedFile::fake()->image('logo.jpg', 200, 500)
])
->assertSessionHasErrors('logo');
}
/** @test */
public function it_can_update_site_favicon()
{
$this->patch(route('admin.settings.update', $this->setting), [
'favicon' => UploadedFile::fake()->image('favicon.jpg', 16, 16)
]);
Storage::disk('public')->assertExists('img/favicon/' . $this->setting->favicon);
}
/** @test */
public function it_throws_error_for_valid_site_favicon()
{
$this->withExceptionHandling();
$this->patch(route('admin.settings.update', $this->setting), [
'favicon' => UploadedFile::fake()->image('favicon.jpg', 200, 500)
])
->assertSessionHasErrors('favicon');
}
}
<?php
namespace Tests\Feature;
use Tests\TestCase;
use App\Models\BlogCategories\BlogCategory;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ManageBlogCategoriesTest extends TestCase
{
/** @test */
public function a_user_can_view_blog_categories_index_page()
{
$this->actingAs($this->admin)
->get(route('admin.blogCategories.index'))
->assertViewIs('backend.blogcategories.index')
->assertSee(trans('labels.backend.blogcategories.management'))
->assertSee(trans('labels.backend.blogcategories.table.title'))
->assertSee(trans('labels.backend.blogcategories.table.status'))
->assertSee('Export')
->assertSee('Action');
}
/** @test */
public function a_user_can_create_a_blog_category()
{
$this->actingAs($this->admin);
$category = make(BlogCategory::class);
$this->post(route('admin.blogCategories.store'), $category->toArray());
$this->assertDatabaseHas(config('module.blog_categories.table'), ['name' => $category->name]);
}
/** @test */
public function a_blog_category_requires_a_name_while_creating()
{
$this->actingAs($this->admin)->withExceptionHandling();
$category = make(BlogCategory::class, ['name' => '']);
$this->post(route('admin.blogCategories.store'), $category->toArray())
->assertSessionHasErrors('name');
}
// public function a_blog_category_requires_a_name_while_updating()
// {
// $this->actingAs($this->admin)->withExceptionHandling();
// $category = create(BlogCategory::class);
// $this->post(route('admin.blogCategories.store'), $category->toArray())
// ->assertSessionHasErrors('name');
// }
/** @test */
public function a_user_can_update_a_blog_category()
{
$this->actingAs($this->admin);
$category = create(BlogCategory::class);
$this->patch(route('admin.blogCategories.update', $category), ['name' => 'New Category']);
$this->assertDatabaseHas(config('module.blog_categories.table'), ['name' => 'New Category', 'id' => $category->id]);
}
/** @test */
public function a_user_can_delete_a_blog_category()
{
$this->actingAs($this->admin);
$category = create(BlogCategory::class);
$this->delete(route('admin.blogCategories.destroy', $category));
$this->assertDatabaseMissing(config('module.blog_categories.table'), ['name' => $category->name, 'id' => $category->id, 'deleted_at' => null]);
}
}
<?php
namespace Tests\Unit;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class BlogCategoryTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testExample()
{
$this->assertTrue(true);
}
}
<?php
namespace Tests\Unit;
use Tests\TestCase;
use App\Models\Page\Page;
use App\Models\Access\User\User;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class PageTest extends TestCase
{
/** @test */
public function it_has_an_owner()
{
$this->actingAs($this->admin);
$page = create(Page::class);
$this->assertInstanceOf(User::class, $page->owner);
}
}
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