Results: 71
Debug errors in Laravel
blade
file on each row
@if ($errors->any())
     @foreach ($errors->all() as $error)
         <div>{{$error}}</div>
     @endforeach
 @endif
Only the post author will be able to delete their own post
public 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');
}
Installing
ckeditor
package for textareas
fields types in mysql table relationships
In
many 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) unsigned
php artisan make:model Asset -m -c -r
Long version of the above command would be:
php artisan make:model Asset --migration --controller --resource
Only the post author will be able to see
delete
and
edit
links
@if (!Auth::guest())
    @if (Auth::user()->id == $post->user_id)
        <!-- delete and edit links -->
    @endif
@endif
Inside
Post
model
public function user() {
    return $this->belongsTo('App\User');
}
Inside
User
model
public function posts() {
    return $this->hasMany('App\Post');
}
Authentication links for guests
@guest
    <!-- Authentication Links for Guests -->
@else
    <!-- HTML for Authenticated Users -->
@endgues
authentication routes
Registers all the necessary routes for authentication
Auth::routes();
We can order posts by
created_at
with
descending
order, to see the newly created posts at the top
Results: 71