Skip to content
This repository has been archived by the owner on Feb 24, 2022. It is now read-only.

SomeFixes and update #15

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class Kernel extends ConsoleKernel
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @param \Illuminate\Console\Scheduling\Schedule $schedule
*
* @return void
*/
protected function schedule(Schedule $schedule)
Expand Down
7 changes: 6 additions & 1 deletion app/Contracts/AttributeContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,36 @@ interface AttributeContract
/**
* @param string $order
* @param string $sort
* @param array $columns
* @param array $columns
*
* @return mixed
*/
public function listAttributes(string $order = 'id', string $sort = 'desc', array $columns = ['*']);

/**
* @param int $id
*
* @return mixed
*/
public function findAttributeById(int $id);

/**
* @param array $params
*
* @return mixed
*/
public function createAttribute(array $params);

/**
* @param array $params
*
* @return mixed
*/
public function updateAttribute(array $params);

/**
* @param $id
*
* @return bool
*/
public function deleteAttribute($id);
Expand Down
45 changes: 31 additions & 14 deletions app/Contracts/BaseContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,73 +3,90 @@
namespace App\Contracts;

/**
* Interface BaseContract
* @package App\Contracts
* Interface BaseContract.
*/
interface BaseContract
{
/**
* Create a model instance
* Create a model instance.
*
* @param array $attributes
*
* @return mixed
*/
public function create(array $attributes);

/**
* Update a model instance
* Update a model instance.
*
* @param array $attributes
* @param int $id
* @param int $id
*
* @return mixed
*/
public function update(array $attributes, int $id);

/**
* Return all model rows
* @param array $columns
* Return all model rows.
*
* @param array $columns
* @param string $orderBy
* @param string $sortBy
*
* @return mixed
*/
public function all($columns = array('*'), string $orderBy = 'id', string $sortBy = 'desc');
public function all($columns = ['*'], string $orderBy = 'id', string $sortBy = 'desc');

/**
* Find one by ID
* Find one by ID.
*
* @param int $id
*
* @return mixed
*/
public function find(int $id);

/**
* Find one by ID or throw exception
* Find one by ID or throw exception.
*
* @param int $id
*
* @return mixed
*/
public function findOneOrFail(int $id);

/**
* Find based on a different column
* Find based on a different column.
*
* @param array $data
*
* @return mixed
*/
public function findBy(array $data);

/**
* Find one based on a different column
* Find one based on a different column.
*
* @param array $data
*
* @return mixed
*/
public function findOneBy(array $data);

/**
* Find one based on a different column or through exception
* Find one based on a different column or through exception.
*
* @param array $data
*
* @return mixed
*/
public function findOneByOrFail(array $data);

/**
* Delete one by Id
* Delete one by Id.
*
* @param int $id
*
* @return mixed
*/
public function delete(int $id);
Expand Down
10 changes: 7 additions & 3 deletions app/Contracts/BrandContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,43 @@
namespace App\Contracts;

/**
* Interface BrandContract
* @package App\Contracts
* Interface BrandContract.
*/
interface BrandContract
{
/**
* @param string $order
* @param string $sort
* @param array $columns
* @param array $columns
*
* @return mixed
*/
public function listBrands(string $order = 'id', string $sort = 'desc', array $columns = ['*']);

/**
* @param int $id
*
* @return mixed
*/
public function findBrandById(int $id);

/**
* @param array $params
*
* @return mixed
*/
public function createBrand(array $params);

/**
* @param array $params
*
* @return mixed
*/
public function updateBrand(array $params);

/**
* @param $id
*
* @return bool
*/
public function deleteBrand($id);
Expand Down
11 changes: 8 additions & 3 deletions app/Contracts/CategoryContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,43 @@
namespace App\Contracts;

/**
* Interface CategoryContract
* @package App\Contracts
* Interface CategoryContract.
*/
interface CategoryContract
{
/**
* @param string $order
* @param string $sort
* @param array $columns
* @param array $columns
*
* @return mixed
*/
public function listCategories(string $order = 'id', string $sort = 'desc', array $columns = ['*']);

/**
* @param int $id
*
* @return mixed
*/
public function findCategoryById(int $id);

/**
* @param array $params
*
* @return mixed
*/
public function createCategory(array $params);

/**
* @param array $params
*
* @return mixed
*/
public function updateCategory(array $params);

/**
* @param $id
*
* @return bool
*/
public function deleteCategory($id);
Expand All @@ -47,6 +51,7 @@ public function treeList();

/**
* @param $slug
*
* @return mixed
*/
public function findBySlug($slug);
Expand Down
11 changes: 8 additions & 3 deletions app/Contracts/ProductContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,50 @@
namespace App\Contracts;

/**
* Interface ProductContract
* @package App\Contracts
* Interface ProductContract.
*/
interface ProductContract
{
/**
* @param string $order
* @param string $sort
* @param array $columns
* @param array $columns
*
* @return mixed
*/
public function listProducts(string $order = 'id', string $sort = 'desc', array $columns = ['*']);

/**
* @param int $id
*
* @return mixed
*/
public function findProductById(int $id);

/**
* @param array $params
*
* @return mixed
*/
public function createProduct(array $params);

/**
* @param array $params
*
* @return mixed
*/
public function updateProduct(array $params);

/**
* @param $id
*
* @return bool
*/
public function deleteProduct($id);

/**
* @param $slug
*
* @return mixed
*/
public function findProductBySlug($slug);
Expand Down
19 changes: 11 additions & 8 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
namespace App\Exceptions;

use Exception;
use Request;
use Response;
use Illuminate\Support\Arr;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Support\Arr;
use Response;

class Handler extends ExceptionHandler
{
Expand All @@ -33,7 +32,8 @@ class Handler extends ExceptionHandler
/**
* Report or log an exception.
*
* @param \Exception $exception
* @param \Exception $exception
*
* @return void
*/
public function report(Exception $exception)
Expand All @@ -44,8 +44,9 @@ public function report(Exception $exception)
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
*
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
Expand All @@ -55,7 +56,8 @@ public function render($request, Exception $exception)

/**
* @param \Illuminate\Http\Request $request
* @param AuthenticationException $exception
* @param AuthenticationException $exception
*
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\Response
*/
protected function unauthenticated($request, AuthenticationException $exception)
Expand All @@ -64,14 +66,15 @@ protected function unauthenticated($request, AuthenticationException $exception)
return response()->json(['message' => $exception->getMessage()], 401);
}
$guard = Arr::get($exception->guards(), 0);
switch($guard){
switch ($guard) {
case 'admin':
$login = 'admin.login';
break;
default:
$login = 'login';
break;
}

return redirect()->guest(route($login));
}
}
Loading