Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

213
Views
Can't pass in data in store method

I cant figure out why I am unable to pass in the "name" in my store method.
this line:- 'name' => $id->name,
I did check and the variable is not null.

Here's My Controller:-

$id = DB::table('friends')
      ->where('created_by', '=', $request->created_by)
      ->where('friends_id', '=', auth()->id())
      ->first();
      dd($id->name);
  if ($id && $id->friends_id == auth()->id()) {

      Post::create([
            'title'=>$data['title'],
            'body'=>$data['body'],
            'created_by'=>$request->created_by,
            'user_id'=>Auth::user()->id,
            'filled_by'=>Auth::user()->uuid,
            'name' => $id->name,

          ]);


  } else {

     Post::create([
            'title'=>$data['title'],
            'body'=>$data['body'],
            'created_by'=>$request->created_by,
            'user_id'=>Auth::user()->id,
            'filled_by'=>Auth::user()->uuid,

          ]);
}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Make sure, in Post the column name field is fillable.

protected $fillable = [
    'title','body','created_by','user_id','filled_by','name'
];

I would recommend you to follow this way of your if condition.

$post = [
    'title'=>$data['title'],
    'body'=>$data['body'],
    'created_by'=>$request->created_by,
    'user_id'=>Auth::user()->id,
    'filled_by'=>Auth::user()->uuid
]

if ($id && $id->friends_id == auth()->id()) {
    $post['name'] = $id->name;
}

Post::create($post);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!