-
composer.json
Open in GitHub{ // "require": { "php": "^7.3", // "spatie/laravel-permission": "^3.17" }, // |
-
app/Models/User.php
Open in GitHubuse Illuminate\Foundation\Auth\User as Authenticatable; use Spatie\Permission\Traits\HasRoles; class User extends Authenticatable { use HasRoles; // }
-
app/Http/Controllers/AccountController.php
Open in GitHubuse App\Models\Post; use RealRashid\SweetAlert\Facades\Alert; class AccountController extends Controller { // public function applyJobView(Request $request) { if ($this->hasApplied(auth()->user(), $request->post_id)) { Alert::toast('You have already applied for this job!', 'success'); return redirect()->route('post.show', ['job' => $request->post_id]); }else if(!auth()->user()->hasRole('user')){ Alert::toast('You are a employer! You can\'t apply for the job! ', 'error'); return redirect()->route('post.show', ['job' => $request->post_id]); } $post = Post::find($request->post_id); $company = $post->company()->first(); return view('account.apply-job', compact('post', 'company')); } // }