×
Clear all filters including search bar
Valeri Tandilashvili's Laravel Notes
blade file on each row@if ($errors->any())
@foreach ($errors->all() as $error)
<div>{{$error}}</div>
@endforeach
@endifpublic function destroy($id)
{
$post = POST::find($id);
// Check for correct user
if (auth()->user()->id !== $post->user_id) {
return redirect('/posts')->with('error', 'Unauthorized page');
}
$post->delete();
return view('posts')->with('success', 'Post Removed');
}ckeditor package for textareasmany to many relationship user_id inside user_roles table must be exactly the same as the id field inside users table
Example: if users->id is bigint(20) unsigned then user_role->user_id must be exactly bigint(20) unsignedphp artisan make:model Asset -m -c -r
Long version of the above command would be:php artisan make:model Asset --migration --controller --resourcedelete and edit links@if (!Auth::guest())
@if (Auth::user()->id == $post->user_id)
<!-- delete and edit links -->
@endif
@endifPost modelpublic function user() {
return $this->belongsTo('App\User');
}
Inside User modelpublic function posts() {
return $this->hasMany('App\Post');
}@guest
<!-- Authentication Links for Guests -->
@else
<!-- HTML for Authenticated Users -->
@endguesAuth::routes();created_at with descending order, to see the newly created posts at the top