Unverified Commit 4145207d authored by Viral Solani's avatar Viral Solani Committed by GitHub

Merge pull request #204 from viralsolani/develop

Merge Develop
parents 2f6984ab 0a5cd047
......@@ -8,7 +8,7 @@
## Introduction
* This is a laravel Admin Panel, based on [Rappasoft Laravel Boilerplate](https://github.com/rappasoft/laravel-5-boilerplate/releases/tag/4.5.7), with enhancemenets and many modules pre-made, just for you.
* The project is taken to Laravel 5.5 so we can develop from the latest Laravel.
* The project is taken to Laravel 5.6 so we can develop from the latest Laravel.
## Features
For Laravel 5 Boilerplate Features : [Features](https://github.com/rappasoft/laravel-5-boilerplate/wiki#features)
......@@ -29,7 +29,7 @@ It gives you the ability to create a module using a sweet GUI, where you put in
## Installation
Please check the official laravel installation guide for server requirements before you start. [Official Documentation](https://laravel.com/docs/5.4/installation#installation)
Please check the official laravel installation guide for server requirements before you start. [Official Documentation](https://laravel.com/docs/5.6/installation#installation)
Clone the repository
......
......@@ -62,9 +62,9 @@ class PagesController extends APIController
return $this->throwValidation($validation->messages()->first());
}
$this->repository->create($request->all());
$page = $this->repository->create($request->all());
return new PagesResource(Page::orderBy('created_at', 'desc')->first());
return new PagesResource($page);
}
/**
......
......@@ -2,7 +2,6 @@
namespace App\Http\Controllers\Api\V1;
use App\Http\Requests\Backend\Access\User\ManageUserRequest;
use App\Http\Resources\UserResource;
use App\Models\Access\User\User;
use App\Repositories\Backend\Access\User\UserRepository;
......@@ -30,7 +29,7 @@ class UsersController extends APIController
*
* @return \Illuminate\Http\JsonResponse
*/
public function index(ManageUserRequest $request)
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
......
......@@ -12,6 +12,6 @@ class VerifyCsrfToken extends BaseVerifier
* @var array
*/
protected $except = [
//
'api/*',
];
}
......@@ -58,7 +58,7 @@ class PagesRepository extends BaseRepository
if ($page = Page::create($input)) {
event(new PageCreated($page));
return true;
return $page;
}
throw new GeneralException(trans('exceptions.backend.pages.create_error'));
......
This diff is collapsed.
......@@ -39,6 +39,15 @@ return [
'Authorization',
],
'expose_headers' => [
'Cache-Control',
'Content-Language',
'Content-Type',
'Expires',
'Last-Modified',
'Pragma',
],
'forbidden_response' => [
'message' => 'Forbidden (cors).',
'status' => 403,
......
......@@ -7,12 +7,18 @@ use Faker\Generator as Faker;
$factory->define(Page::class, function (Faker $faker) {
$title = $faker->sentence;
$newestPage = Page::orderBy('id', 'desc')->first();
return [
'title' => $title,
'page_slug' => str_slug($title),
'description' => $faker->paragraph,
'created_by' => function () {
'title' => $title,
'page_slug' => str_slug($title),
'description' => $faker->paragraph,
'cannonical_link' => 'http://localhost:8000/'.str_slug($title),
'created_by' => function () {
return factory(User::class)->create()->id;
},
'status' => 1,
'created_at' => Carbon\Carbon::now(),
'updated_at' => Carbon\Carbon::now(),
];
});
......@@ -370,7 +370,7 @@ var Backend = {}; // common variable used in all the files of the backend
if (request.status >= 200 && request.status < 400) {
// Success!
response = request.responseText;
Backend.Blog.selectors.slug.value = Backend.Blog.selectors.SlugUrl + '/' + response;
Backend.Blog.selectors.slug.value = Backend.Blog.selectors.SlugUrl + '/' + response.trim();
}
},
error: function (request) {
......
<?php
namespace Tests\Feature\Api\V1;
use App\Models\Access\User\User;
use App\Models\Page\Page;
use JWTAuth;
use Tests\TestCase;
class PageTest extends TestCase
{
public $token = '';
public $headers = '';
public $user = '';
public function setUp()
{
parent::setUp();
$this->user = User::find(1);
$this->token = JWTAuth::fromUser($this->user);
$this->headers = ['Authorization' => 'Bearer '.$this->token];
}
/**
* A basic test example.
*
* @return void
*/
public function testExample()
{
$this->assertTrue(true);
}
/**
* A basic test to get response form pages api.
*
* @return void
*/
/** @test */
public function Get_records_from_pages()
{
$payload = [];
$response = $this->json('GET', '/api/v1/pages', $payload, $this->headers);
$response
->assertStatus(200)
->assertJsonStructure([
'data'=> [
[
'id',
'title',
'status_label',
'status',
'created_at',
'created_by',
],
],
'links',
'meta',
]);
}
/**
* A basic test to get response form pages api.
*
* @return void
*/
/** @test */
public function get_one_created_page_from_db()
{
$page = create(Page::class);
$payload = [];
$response = $this->json('GET', '/api/v1/pages/'.$page->id, $payload, $this->headers);
$response
->assertStatus(200)
->assertJson([
'data'=> [
'id' => $page->id,
'title' => $page->title,
'status_label' => $page->status_label,
'status' => ($page->isActive()) ? 'Active' : 'InActive',
'created_by' => $page->created_by,
],
]);
}
/**
* Author: Indra Shastri
* Date:03-03-2018
* A basic test to update a page from api.
*
*
* @return void
*/
/** @test */
public function update_a_page_in_db_and_get_response()
{
$page = make(Page::class);
$payload = [
'title' => $page->title,
'description' => $page->description,
'cannonical_link' => $page->cannonical_link,
'seo_title' => 'some tittle',
'seo_keyword' => 'some keywords',
'seo_description' => '<p>&nbsp;</p>↵<h1>SEO Description</h1>↵<p>some seco desctription</p>↵<p>askdsaj;ldsjfd</p>',
'status' => '1',
];
$response = '';
$response = $this->json('PUT', '/api/v1/pages/1', $payload, $this->headers);
$response->assertStatus(200);
$response->assertJson([
'data'=> [
'title' => $page->title,
'status_label' => $page->status_label,
'status' => ($page->isActive()) ? 'Active' : 'InActive',
'created_by' => ''.$this->user->id,
],
]);
}
/**
* Author: Indra Shastri
* Date:03-03-2018
* A basic test to create a page from api.
*
* @return void
*/
/** @test */
public function create_a_new_page_in_db_and_get_response()
{
$page = make(Page::class);
$payload = [
'title' => $page->title,
'description' => $page->description,
'cannonical_link' => $page->cannonical_link,
'seo_title' => 'some tittle',
'seo_keyword' => 'some keywords',
'seo_description' => '<p>&nbsp;</p>↵<h1>SEO Description</h1>↵<p>some seco desctription</p>↵<p>askdsaj;ldsjfd</p>',
'status' => '1',
];
$response = '';
$response = $this->json('POST', '/api/v1/pages', $payload, $this->headers);
$response->assertStatus(201);
$response->assertJson([
'data' => [
'title' => $page->title,
'status_label' => $page->status_label,
'status' => ($page->isActive()) ? 'Active' : 'InActive',
'created_by' => $this->user->first_name,
'created_at' => (\Carbon\Carbon::now())->toDateString(),
],
]);
}
/**
* Author: Indra Shastri
* Date:03-03-2018
* A basic test to create a page from api.
*
* @return void
*/
/** @test */
public function delete_page_in_db_and_get_response()
{
$page = create(Page::class);
$payload = [];
$response = $this->json('DELETE', '/api/v1/pages/'.$page->id, $payload, $this->headers);
$response->assertStatus(200)
->assertJson([
'message'=> 'The Page was successfully deleted.',
]);
}
}
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