This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
class Restaurant extends Model | |
{ | |
public function reviews() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use App\Review; | |
use Illuminate\Http\Request; | |
class ReviewController extends Controller | |
{ | |
public function results() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Database\Migrations\Migration; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Support\Facades\Schema; | |
class CreateAclsTable extends Migration | |
{ | |
/** | |
* Run the migrations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> select * from acls; | |
+----+-----------------------------+-------------+---------------------+---------------------+ | |
| id | resource | role | created_at | updated_at | | |
+----+-----------------------------+-------------+---------------------+---------------------+ | |
| 1 | ReviewController@store | ROLE_BASIC | 2019-11-04 21:53:18 | 2019-11-04 21:53:18 | | |
| 2 | RestaurantController@index | ROLE_EDITOR | 2019-11-04 21:53:18 | 2019-11-04 21:53:18 | | |
| 3 | RestaurantController@show | ROLE_EDITOR | 2019-11-04 21:53:18 | 2019-11-04 21:53:18 | | |
| 4 | RestaurantController@update | ROLE_EDITOR | 2019-11-04 21:53:18 | 2019-11-04 21:53:18 | | |
| 5 | RestaurantController@delete | ROLE_EDITOR | 2019-11-04 21:53:18 | 2019-11-04 21:53:18 | | |
| 6 | ReviewController@delete | ROLE_EDITOR | 2019-11-04 21:53:18 | 2019-11-04 21:53:18 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ... | |
/** | |
* The application's route middleware. | |
* | |
* These middleware may be assigned to groups or used individually. | |
* | |
* @var array | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Http\Request; | |
Route::post('/auth/login', 'AuthController@login'); | |
Route::post('/auth/logout', 'AuthController@logout')->middleware('jwt.authorizer'); | |
Route::get('restaurants', 'RestaurantController@index')->middleware('jwt.authorizer', 'acl'); | |
Route::get('restaurants/{restaurant}', 'RestaurantController@show')->middleware('jwt.authorizer', 'acl'); | |
Route::post('restaurants', 'RestaurantController@store')->middleware('jwt.authorizer', 'acl'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
read -p "This will bootstrap the development environment. Are you sure to continue? (y|n) " -n 1 -r | |
echo # (optional) move to a new line | |
if [[ ! $REPLY =~ ^[Yy]$ ]] | |
then | |
exit 1 | |
fi | |
# cd the app's root directory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Console\Commands; | |
use App\Acl; | |
use Illuminate\Console\Command; | |
class AclSetup extends Command | |
{ | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Requests; | |
class StoreRestaurant extends AbstractAuthorizedFormRequest | |
{ | |
/** | |
* Get the validation rules that apply to the request. | |
* | |
* @return array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use App\User; | |
use Illuminate\Database\Eloquent\Model; | |
class Acl extends Model | |
{ | |
protected $fillable = ['resource', 'role']; |
OlderNewer