#so i got a error massage 404 not found

11 messages · Page 1 of 1 (latest)

worldly hill
#

i try to parse the data with get as it take the data from the user authenticated then bring them to another database
this is the controller side

namespace App\Http\Controllers;

use App\Models\Job;
use App\Models\User;
use App\Models\Applicant;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

    public function apply(Job $job){
        
        $job = Job::findorfail($job->id);
        if(Auth::guest()){
            return redirect()->route('login')->with('error','anda musti anggota');
        }
        else{
            $apply= new Applicant([
                'name'=> $job->name,
                'email'=> Auth::user()->email,
                'job_id'=>$job->job_id,
                'user_id'=>Auth::user()->user_id,
            ]);
            $apply->save();
            return redirect()->route('jobs.search')->with('success','anda berhasil mendaftar');
        }
    }

and here is the route

Route::get('/apply/{job}', [ApplicantController::class, 'apply'])->name('apply')->middleware('auth');
orchid heart
#

If you're typehinting the Job you don't need to do $job = Job::findorfail($job->id);

#

Try doing dd($job) at the top of your controller method and see if it prints the iob model

#

if that still doesn't work, remove the Job typehint and try doing dd($job) and see if it prints the ID provided in the URL

sick tide
#

@worldly hill You don’t need this if statement:

if(Auth::guest()){
    return redirect()->route('login')->with('error','anda musti anggota');
}

If you use the auth middleware instead.

Can you please do some tutorials or watch some videos, as you clearly don’t have a solid understand of Laravel fundamentals yet.

worldly hill
#

it did print the url

worldly hill
orchid heart
#

there are some free courses you can use to get up to speed

forest lava
# worldly hill can you give me a few video channel that can give me a good fundamental on larav...

Like Dan said, use laracasts, start with this course:

https://laracasts.com/series/laravel-8-from-scratch

Laracasts

We don't learn tools for the sake of learning tools. Instead, we learn them because they help us accomplish a particular goal. With that in mind, in this series, we'll use the common desire for a blog - with categories, tags, comments, email notifications, and more - as our goal. Laravel will be the tool that helps us get there. Each lesson, ge...