Commit c5c8c63d authored by Vipul Basapati's avatar Vipul Basapati

conflicts resolved

parents c68b710a 8b8ac133
......@@ -5,7 +5,6 @@ namespace App\Http\Controllers\Backend\Pages;
use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Pages\ManagePageRequest;
use App\Repositories\Backend\Pages\PagesRepository;
use Carbon\Carbon;
use Yajra\DataTables\Facades\DataTables;
/**
......
......@@ -7,7 +7,6 @@ use App\Http\Requests\Backend\Settings\ManageSettingsRequest;
use App\Http\Requests\Backend\Settings\UpdateSettingsRequest;
use App\Models\Settings\Setting;
use App\Repositories\Backend\Settings\SettingsRepository;
use Illuminate\Http\Request;
/**
* Class SettingsController.
......@@ -45,7 +44,7 @@ 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'));
......
......@@ -23,10 +23,10 @@ class SettingsLogoController extends Controller
}
/**
* Remove logo or favicon icon
*
* Remove logo or favicon icon.
*
* @param \App\Models\Settings\Setting $setting
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
*
* @return mixed
*/
......@@ -35,7 +35,7 @@ class SettingsLogoController extends Controller
$this->settings->removeLogo($setting, $request->data);
return json_encode([
'status' => true
'status' => true,
]);
}
}
......@@ -4,9 +4,9 @@ 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
{
......@@ -32,12 +32,12 @@ class Page extends BaseModel
protected $guarded = ['id'];
/**
* The default values for attributes
* The default values for attributes.
*
* @var array
*/
protected $attributes = [
'created_by' => 1
'created_by' => 1,
];
protected $with = ['owner'];
......
......@@ -4,11 +4,10 @@ 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
*/
......
......@@ -32,7 +32,7 @@ class PagesRepository extends BaseRepository
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'
config('access.users_table').'.first_name as created_by',
]);
}
......
......@@ -2,8 +2,8 @@
namespace App\Repositories\Backend\Settings;
use App\Models\Settings\Setting;
use App\Exceptions\GeneralException;
use App\Models\Settings\Setting;
use App\Repositories\BaseRepository;
use Illuminate\Support\Facades\Storage;
......@@ -18,39 +18,39 @@ class SettingsRepository extends BaseRepository
const MODEL = Setting::class;
/**
* Site Logo Path
* Site Logo Path.
*
* @var string
*/
protected $site_logo_path;
/**
* Favicon path
* Favicon path.
*
* @var string
*/
protected $favicon_path;
/**
* Storage Class Object
* Storage Class Object.
*
* @var \Illuminate\Support\Facades\Storage
*/
protected $storage;
/**
* Constructor
* Constructor.
*/
public function __construct()
{
$this->site_logo_path = 'img'. DIRECTORY_SEPARATOR . 'logo' . DIRECTORY_SEPARATOR;
$this->favicon_path = 'img' . DIRECTORY_SEPARATOR . 'favicon' . DIRECTORY_SEPARATOR;
$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 Array $input
* @param array $input
*
* @throws \App\Exceptions\GeneralException
*
......@@ -58,20 +58,21 @@ class SettingsRepository extends BaseRepository
*/
public function update(Setting $setting, array $input)
{
if (! empty($input['logo'])) {
if (!empty($input['logo'])) {
$this->removeLogo($setting, 'logo');
$input['logo'] = $this->uploadLogo($setting, $input['logo'], 'logo');
}
if (! empty($input['favicon'])) {
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'));
}
......@@ -81,11 +82,11 @@ class SettingsRepository extends BaseRepository
*/
public function uploadLogo($setting, $logo, $type)
{
$path = $type == "logo" ? $this->site_logo_path : $this->favicon_path;
$path = $type == 'logo' ? $this->site_logo_path : $this->favicon_path;
$image_name = time() . $logo->getClientOriginalName();
$image_name = time().$logo->getClientOriginalName();
$this->storage->put($path . $image_name, file_get_contents($logo->getRealPath()));
$this->storage->put($path.$image_name, file_get_contents($logo->getRealPath()));
return $image_name;
}
......@@ -95,15 +96,17 @@ class SettingsRepository extends BaseRepository
*/
public function removeLogo(Setting $setting, $type)
{
$path = $type == "logo" ? $this->site_logo_path : $this->favicon_path;
$path = $type == 'logo' ? $this->site_logo_path : $this->favicon_path;
if ($setting->$type && $this->storage->exists($path . $setting->$type)) {
$this->storage->delete($path . $setting->$type);
if ($setting->$type && $this->storage->exists($path.$setting->$type)) {
$this->storage->delete($path.$setting->$type);
}
$result = $setting->update([ $type => null ]);
$result = $setting->update([$type => null]);
if($result) return true;
if ($result) {
return true;
}
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;
use Faker\Generator as Faker;
$factory->define(BlogCategory::class, function (Faker $faker) {
return [
'name' => $faker->word,
'status' => $faker->numberBetween(0, 1),
'name' => $faker->word,
'status' => $faker->numberBetween(0, 1),
'created_by' => function () {
return factory(User::class)->create()->id;
},
......
......@@ -2,10 +2,8 @@
namespace Tests\Feature\Backend;
use Tests\TestCase;
use App\Models\BlogCategories\BlogCategory;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ManageBlogCategoriesTest extends TestCase
{
......@@ -17,7 +15,7 @@ class ManageBlogCategoriesTest extends TestCase
->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(trans('labels.backend.blogcategories.table.status'))
->assertSee('Export')
->assertSee('Action');
}
......@@ -26,9 +24,9 @@ class ManageBlogCategoriesTest extends TestCase
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]);
......
......@@ -2,12 +2,10 @@
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;
use Tests\TestCase;
class ManageSettingsTest extends TestCase
{
......@@ -37,10 +35,10 @@ class ManageSettingsTest extends TestCase
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)
'logo' => UploadedFile::fake()->image('logo.jpg', 226, 48),
]);
Storage::disk('public')->assertExists('img/logo/' . $this->setting->logo);
Storage::disk('public')->assertExists('img/logo/'.$this->setting->logo);
}
/** @test */
......@@ -49,7 +47,7 @@ class ManageSettingsTest extends TestCase
$this->withExceptionHandling();
$this->patch(route('admin.settings.update', $this->setting), [
'logo' => UploadedFile::fake()->image('logo.jpg', 200, 500)
'logo' => UploadedFile::fake()->image('logo.jpg', 200, 500),
])
->assertSessionHasErrors('logo');
}
......@@ -58,10 +56,10 @@ class ManageSettingsTest extends TestCase
public function it_can_update_site_favicon()
{
$this->patch(route('admin.settings.update', $this->setting), [
'favicon' => UploadedFile::fake()->image('favicon.jpg', 16, 16)
'favicon' => UploadedFile::fake()->image('favicon.jpg', 16, 16),
]);
Storage::disk('public')->assertExists('img/favicon/' . $this->setting->favicon);
Storage::disk('public')->assertExists('img/favicon/'.$this->setting->favicon);
}
/** @test */
......@@ -70,7 +68,7 @@ class ManageSettingsTest extends TestCase
$this->withExceptionHandling();
$this->patch(route('admin.settings.update', $this->setting), [
'favicon' => UploadedFile::fake()->image('favicon.jpg', 200, 500)
'favicon' => UploadedFile::fake()->image('favicon.jpg', 200, 500),
])
->assertSessionHasErrors('favicon');
}
......
......@@ -2,11 +2,9 @@
namespace Tests\Unit\Models;
use Tests\TestCase;
use App\Models\Page\Page;
use App\Models\Access\User\User;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Models\Page\Page;
use Tests\TestCase;
class PageTest extends TestCase
{
......@@ -16,7 +14,7 @@ class PageTest extends TestCase
$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