Unverified Commit d5b43677 authored by Vipul Basapati's avatar Vipul Basapati Committed by GitHub

Merge pull request #213 from bvipul/develop

Added Responsable interface implementation for BlogsController.
parents 595f1cbe 9044ce45
...@@ -33,6 +33,8 @@ REDIS_PORT=6379 ...@@ -33,6 +33,8 @@ REDIS_PORT=6379
MAIL_DRIVER=smtp MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525 MAIL_PORT=2525
MAIL_FROM=viral.solani@gmail.com
MAIL_FROM_NAME=Admin
MAIL_USERNAME=null MAIL_USERNAME=null
MAIL_PASSWORD=null MAIL_PASSWORD=null
MAIL_ENCRYPTION=null MAIL_ENCRYPTION=null
......
...@@ -6,6 +6,10 @@ use App\Http\Controllers\Controller; ...@@ -6,6 +6,10 @@ use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Blogs\ManageBlogsRequest; use App\Http\Requests\Backend\Blogs\ManageBlogsRequest;
use App\Http\Requests\Backend\Blogs\StoreBlogsRequest; use App\Http\Requests\Backend\Blogs\StoreBlogsRequest;
use App\Http\Requests\Backend\Blogs\UpdateBlogsRequest; use App\Http\Requests\Backend\Blogs\UpdateBlogsRequest;
use App\Http\Responses\Backend\Blog\IndexResponse;
use App\Http\Responses\Backend\Blog\CreateResponse;
use App\Http\Responses\Backend\Blog\EditResponse;
use App\Http\Responses\RedirectResponse;
use App\Models\BlogCategories\BlogCategory; use App\Models\BlogCategories\BlogCategory;
use App\Models\Blogs\Blog; use App\Models\Blogs\Blog;
use App\Models\BlogTags\BlogTag; use App\Models\BlogTags\BlogTag;
...@@ -46,9 +50,7 @@ class BlogsController extends Controller ...@@ -46,9 +50,7 @@ class BlogsController extends Controller
*/ */
public function index(ManageBlogsRequest $request) public function index(ManageBlogsRequest $request)
{ {
return view('backend.blogs.index')->with([ return new IndexResponse($this->status);
'status'=> $this->status,
]);
} }
/** /**
...@@ -61,11 +63,7 @@ class BlogsController extends Controller ...@@ -61,11 +63,7 @@ class BlogsController extends Controller
$blogTags = BlogTag::getSelectData(); $blogTags = BlogTag::getSelectData();
$blogCategories = BlogCategory::getSelectData(); $blogCategories = BlogCategory::getSelectData();
return view('backend.blogs.create')->with([ return new CreateResponse($this->status, $blogCategories, $blogTags);
'blogCategories' => $blogCategories,
'blogTags' => $blogTags,
'status' => $this->status,
]);
} }
/** /**
...@@ -77,9 +75,7 @@ class BlogsController extends Controller ...@@ -77,9 +75,7 @@ class BlogsController extends Controller
{ {
$this->blog->create($request->except('_token')); $this->blog->create($request->except('_token'));
return redirect() return new RedirectResponse('admin.blogs.index', ['flash_success' => trans('alerts.backend.blogs.created')]);
->route('admin.blogs.index')
->with('flash_success', trans('alerts.backend.blogs.created'));
} }
/** /**
...@@ -93,17 +89,7 @@ class BlogsController extends Controller ...@@ -93,17 +89,7 @@ class BlogsController extends Controller
$blogCategories = BlogCategory::getSelectData(); $blogCategories = BlogCategory::getSelectData();
$blogTags = BlogTag::getSelectData(); $blogTags = BlogTag::getSelectData();
$selectedCategories = $blog->categories->pluck('id')->toArray(); return new EditResponse($blog, $this->status, $blogCategories, $blogTags);
$selectedtags = $blog->tags->pluck('id')->toArray();
return view('backend.blogs.edit')->with([
'blog' => $blog,
'blogCategories' => $blogCategories,
'blogTags' => $blogTags,
'selectedCategories' => $selectedCategories,
'selectedtags' => $selectedtags,
'status' => $this->status,
]);
} }
/** /**
...@@ -118,9 +104,7 @@ class BlogsController extends Controller ...@@ -118,9 +104,7 @@ class BlogsController extends Controller
$this->blog->update($blog, $request->except(['_token', '_method'])); $this->blog->update($blog, $request->except(['_token', '_method']));
return redirect() return new RedirectResponse('admin.blogs.index', ['flash_success' => trans('alerts.backend.blogs.updated')]);
->route('admin.blogs.index')
->with('flash_success', trans('alerts.backend.blogs.updated'));
} }
/** /**
...@@ -133,8 +117,6 @@ class BlogsController extends Controller ...@@ -133,8 +117,6 @@ class BlogsController extends Controller
{ {
$this->blog->delete($blog); $this->blog->delete($blog);
return redirect() return new RedirectResponse('admin.blogs.index', ['flash_success' => trans('alerts.backend.blogs.deleted')]);
->route('admin.blogs.index')
->with('flash_success', trans('alerts.backend.blogs.deleted'));
} }
} }
<?php
namespace App\Http\Responses\Backend\Blog;
use Illuminate\Contracts\Support\Responsable;
class CreateResponse implements Responsable
{
protected $status,
$blogTags,
$blogCategories;
public function __construct($status, $blogCategories, $blogTags)
{
$this->status = $status;
$this->blogTags = $blogTags;
$this->blogCategories = $blogCategories;
}
public function toResponse($request)
{
return view('backend.blogs.create')->with([
'blogCategories' => $this->blogCategories,
'blogTags' => $this->blogTags,
'status' => $this->status,
]);
}
}
\ No newline at end of file
<?php
namespace App\Http\Responses\Backend\Blog;
use Illuminate\Contracts\Support\Responsable;
class EditResponse implements Responsable
{
protected $blog,
$status,
$blogTags,
$blogCategories;
public function __construct($blog, $status, $blogCategories, $blogTags)
{
$this->blog = $blog;
$this->status = $status;
$this->blogTags = $blogTags;
$this->blogCategories = $blogCategories;
}
public function toResponse($request)
{
$selectedCategories = $this->blog->categories->pluck('id')->toArray();
$selectedtags = $this->blog->tags->pluck('id')->toArray();
return view('backend.blogs.edit')->with([
'blog' => $this->blog,
'blogCategories' => $this->blogCategories,
'blogTags' => $this->blogTags,
'selectedCategories' => $selectedCategories,
'selectedtags' => $selectedtags,
'status' => $this->status,
]);
}
}
\ No newline at end of file
<?php
namespace App\Http\Responses\Backend\Blog;
use Illuminate\Contracts\Support\Responsable;
class IndexResponse implements Responsable
{
protected $status;
public function __construct($status)
{
$this->status = $status;
}
public function toResponse($request)
{
return view('backend.blogs.index')->with([
'status'=> $this->status,
]);
}
}
\ No newline at end of file
<?php
namespace App\Http\Responses;
use Illuminate\Contracts\Support\Responsable;
class RedirectResponse implements Responsable
{
protected $route,
$message;
public function __construct($route, $message)
{
$this->route = $route;
$this->message = $message;
}
public function toResponse($request)
{
return redirect()
->route($this->route)
->with($this->message);
}
}
\ No newline at end of file
...@@ -56,7 +56,7 @@ return [ ...@@ -56,7 +56,7 @@ return [
*/ */
'from' => [ 'from' => [
'address' => env('MAIL_USERNAME', 'viral.solani@gmail.com'), 'address' => env('MAIL_FROM', 'viral.solani@gmail.com'),
'name' => env('MAIL_FROM_NAME', 'Admin'), 'name' => env('MAIL_FROM_NAME', 'Admin'),
], ],
......
...@@ -16,7 +16,6 @@ class ManageBlogCategoriesTest extends TestCase ...@@ -16,7 +16,6 @@ class ManageBlogCategoriesTest extends TestCase
->assertSee(trans('labels.backend.blogcategories.management')) ->assertSee(trans('labels.backend.blogcategories.management'))
->assertSee(trans('labels.backend.blogcategories.table.title')) ->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'); ->assertSee('Action');
} }
......
...@@ -16,7 +16,6 @@ class ManageBlogTagsTest extends TestCase ...@@ -16,7 +16,6 @@ class ManageBlogTagsTest extends TestCase
->assertSee(trans('labels.backend.blogtags.management')) ->assertSee(trans('labels.backend.blogtags.management'))
->assertSee(trans('labels.backend.blogtags.table.title')) ->assertSee(trans('labels.backend.blogtags.table.title'))
->assertSee(trans('labels.backend.blogtags.table.status')) ->assertSee(trans('labels.backend.blogtags.table.status'))
->assertSee('Export')
->assertSee('Action'); ->assertSee('Action');
} }
......
...@@ -39,7 +39,6 @@ class ManageBlogsTest extends TestCase ...@@ -39,7 +39,6 @@ class ManageBlogsTest extends TestCase
->assertSee(trans('labels.backend.blogs.table.createdby')) ->assertSee(trans('labels.backend.blogs.table.createdby'))
->assertSee(trans('labels.backend.blogs.table.createdat')) ->assertSee(trans('labels.backend.blogs.table.createdat'))
->assertSee(trans('labels.backend.blogs.table.status')) ->assertSee(trans('labels.backend.blogs.table.status'))
->assertSee('Export')
->assertSee('Action'); ->assertSee('Action');
} }
......
...@@ -17,7 +17,6 @@ class ManageFaqsTest extends TestCase ...@@ -17,7 +17,6 @@ class ManageFaqsTest extends TestCase
->assertSee(trans('labels.backend.faqs.table.question')) ->assertSee(trans('labels.backend.faqs.table.question'))
->assertSee(trans('labels.backend.faqs.table.answer')) ->assertSee(trans('labels.backend.faqs.table.answer'))
->assertSee(trans('labels.backend.faqs.table.status')) ->assertSee(trans('labels.backend.faqs.table.status'))
->assertSee('Export')
->assertSee('Action'); ->assertSee('Action');
} }
......
...@@ -18,7 +18,6 @@ class ManagePermissionsTest extends TestCase ...@@ -18,7 +18,6 @@ class ManagePermissionsTest extends TestCase
->get(route('admin.access.permission.index')) ->get(route('admin.access.permission.index'))
->assertViewIs('backend.access.permissions.index') ->assertViewIs('backend.access.permissions.index')
->assertSee(trans('labels.backend.access.permissions.management')) ->assertSee(trans('labels.backend.access.permissions.management'))
->assertSee('Export')
->assertSee('Action'); ->assertSee('Action');
} }
......
...@@ -20,7 +20,6 @@ class ManageRolesTest extends TestCase ...@@ -20,7 +20,6 @@ class ManageRolesTest extends TestCase
->get(route('admin.access.role.index')) ->get(route('admin.access.role.index'))
->assertViewIs('backend.access.roles.index') ->assertViewIs('backend.access.roles.index')
->assertSee(trans('labels.backend.access.roles.management')) ->assertSee(trans('labels.backend.access.roles.management'))
->assertSee('Export')
->assertSee('Action'); ->assertSee('Action');
} }
......
...@@ -44,7 +44,6 @@ class ManageUsersTest extends TestCase ...@@ -44,7 +44,6 @@ class ManageUsersTest extends TestCase
->assertViewIs('backend.access.users.index') ->assertViewIs('backend.access.users.index')
->assertSee(trans('labels.backend.access.users.management')) ->assertSee(trans('labels.backend.access.users.management'))
->assertSee(trans('labels.backend.access.users.active')) ->assertSee(trans('labels.backend.access.users.active'))
->assertSee('Export')
->assertSee('Action'); ->assertSee('Action');
} }
...@@ -56,7 +55,6 @@ class ManageUsersTest extends TestCase ...@@ -56,7 +55,6 @@ class ManageUsersTest extends TestCase
->assertViewIs('backend.access.users.deactivated') ->assertViewIs('backend.access.users.deactivated')
->assertSee(trans('labels.backend.access.users.management')) ->assertSee(trans('labels.backend.access.users.management'))
->assertSee(trans('labels.backend.access.users.deactivated')) ->assertSee(trans('labels.backend.access.users.deactivated'))
->assertSee('Export')
->assertSee('Action'); ->assertSee('Action');
} }
...@@ -68,7 +66,6 @@ class ManageUsersTest extends TestCase ...@@ -68,7 +66,6 @@ class ManageUsersTest extends TestCase
->assertViewIs('backend.access.users.deleted') ->assertViewIs('backend.access.users.deleted')
->assertSee(trans('labels.backend.access.users.management')) ->assertSee(trans('labels.backend.access.users.management'))
->assertSee(trans('labels.backend.access.users.deleted')) ->assertSee(trans('labels.backend.access.users.deleted'))
->assertSee('Export')
->assertSee('Action'); ->assertSee('Action');
} }
......
...@@ -24,12 +24,6 @@ class LoggedOutRouteTest extends BrowserKitTestCase ...@@ -24,12 +24,6 @@ class LoggedOutRouteTest extends BrowserKitTestCase
$this->visit('/')->assertResponseOk(); $this->visit('/')->assertResponseOk();
} }
/** @test */
public function test_macroPage()
{
$this->visit('/macros')->see('Macro Examples');
}
/** @test */ /** @test */
public function testLoginPage() public function testLoginPage()
{ {
......
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