This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create Presents * Roles and permissions * Grid / table layout
- Loading branch information
1 parent
f926138
commit ac94c6d
Showing
24 changed files
with
740 additions
and
25,067 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Http\Requests\FormCreatePresentRequest; | ||
use App\Models\Presents; | ||
use Illuminate\Http\Request; | ||
|
||
class PresentsController extends Controller | ||
{ | ||
public function show(Request $request) | ||
{ | ||
$view = $request->input('view','grid'); | ||
|
||
$presents = Presents::all(); | ||
|
||
return view('presents', compact('presents','view')); | ||
} | ||
|
||
public function createPresent(Request $request) { | ||
$user = auth()->user(); | ||
if(empty($user) || !$user->hasPermissionTo('createPresent')) { | ||
abort(403,'no permission'); | ||
} | ||
return view('presents-create'); | ||
} | ||
|
||
|
||
public function storePresent(FormCreatePresentRequest $request) { | ||
$present = new Presents($request->all()); | ||
$present->save(); | ||
return redirect()->route('presents.show') | ||
->with('success','Present was created successfully.'); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class FormCreatePresentRequest extends FormRequest | ||
{ | ||
/** | ||
* Determine if the user is authorized to make this request. | ||
* | ||
* @return bool | ||
*/ | ||
public function authorize() | ||
{ | ||
$user = auth()->user(); | ||
if(empty($user)) { | ||
return false; | ||
} else { | ||
return $user->hasPermissionTo('createPresent');; | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array | ||
*/ | ||
public function rules() | ||
{ | ||
return [ | ||
// | ||
'title' => 'string|max:255|required' | ||
]; | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.