-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Middleware admin si implementare roluri. Design pagina de welcome inc…
…eput
- Loading branch information
Showing
15 changed files
with
11,833 additions
and
133 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
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,24 @@ | ||
<?php | ||
|
||
namespace App\Http\Middleware; | ||
|
||
use Closure; | ||
use Illuminate\Http\Request; | ||
|
||
class IsAdmin | ||
{ | ||
/** | ||
* Handle an incoming request. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next | ||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse | ||
*/ | ||
public function handle(Request $request, Closure $next) | ||
{ | ||
if(auth()->user() && auth()->user()->role=="admin"){ | ||
return $next($request); | ||
} | ||
return redirect('dashboard'); | ||
} | ||
} |
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
39 changes: 39 additions & 0 deletions
39
database/migrations/2022_12_14_192427_add_fields_to_users_table.php
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,39 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::table('users', function (Blueprint $table) { | ||
$table->string('role')->default('editor')->nullable(); | ||
$table->string('profile_picture')->default('default.png')->nullable(); | ||
$table->string('phone')->nullable(); | ||
$table->string('address')->nullable(); | ||
|
||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::table('Users', function (Blueprint $table) { | ||
$table->dropColumn('role'); | ||
$table->dropColumn('profile_picture'); | ||
$table->dropColumn('phone'); | ||
$table->dropColumn('address'); | ||
}); | ||
} | ||
}; |
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
namespace Database\Seeders; | ||
|
||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents; | ||
use App\Models\User; | ||
use Illuminate\Database\Seeder; | ||
|
||
class DatabaseSeeder extends Seeder | ||
|
@@ -15,6 +16,14 @@ class DatabaseSeeder extends Seeder | |
public function run() | ||
{ | ||
\App\Models\User::factory(100)->create(); | ||
User::create([ | ||
'name' => 'Administrator', | ||
'email' => '[email protected]', | ||
'password'=>bcrypt('password'), | ||
'phone' => '+40734124908', | ||
'address' => 'Bucuresti', | ||
'role' => 'admin' | ||
]); | ||
|
||
// \App\Models\User::factory()->create([ | ||
// 'name' => 'Test User', | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.