Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Basic functions
Browse files Browse the repository at this point in the history
* Create Presents
* Roles and permissions
* Grid / table layout
  • Loading branch information
lightszentip committed Jan 4, 2022
1 parent f926138 commit ac94c6d
Show file tree
Hide file tree
Showing 24 changed files with 740 additions and 25,067 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Presentlist / Geschenkeliste #

## Setup

To create default user and permission

````shell
php artisan migrate
php artisan db:seed
````



http://lightszentip.github.io/giftlist/

[![Build Status](https://travis-ci.org/lightszentip/giftlist.svg?branch=master)](https://travis-ci.org/lightszentip/giftlist)
Expand Down
35 changes: 35 additions & 0 deletions app/Http/Controllers/PresentsController.php
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.');
}
}
3 changes: 3 additions & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,8 @@ class Kernel extends HttpKernel
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class,
];
}
37 changes: 37 additions & 0 deletions app/Http/Requests/FormCreatePresentRequest.php
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'
];
}
}
7 changes: 7 additions & 0 deletions app/Models/Presents.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ public function links()
return $this->hasMany(PresentLinks::class);
}

/**
* {@inheritdoc}
*/
protected $guarded = [
'id', 'created_at', 'updated_at',
];

public function usePresent(bool $isCodeActive = false)
{
$this->status = 1;
Expand Down
2 changes: 2 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Laravel\Fortify\TwoFactorAuthenticatable;
use Laravel\Jetstream\HasProfilePhoto;
use Laravel\Sanctum\HasApiTokens;
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
{
Expand All @@ -17,6 +18,7 @@ class User extends Authenticatable
use HasProfilePhoto;
use Notifiable;
use TwoFactorAuthenticatable;
use HasRoles;

/**
* The attributes that are mass assignable.
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RouteServiceProvider extends ServiceProvider
*
* @var string
*/
public const HOME = '/dashboard';
public const HOME = '/';

/**
* The controller namespace for the application.
Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
"license": "MIT",
"require": {
"php": "^7.4|^8.0",
"fruitcake/laravel-cors": "^2.0",
"fruitcake/laravel-cors": "^2.0.5",
"guzzlehttp/guzzle": "^7.4.1",
"laravel/framework": "^8.77.1",
"laravel/jetstream": "^2.5.0",
"laravel/jetstream": "^2.5.1",
"laravel/sanctum": "^2.13",
"laravel/tinker": "^2.6",
"livewire/livewire": "^2.8"
"laravel/tinker": "^v2.6.3",
"livewire/livewire": "^v2.8.2",
"spatie/laravel-permission": "^5.4"
},
"require-dev": {
"facade/ignition": "^2.5",
Expand Down
Loading

0 comments on commit ac94c6d

Please sign in to comment.