App\Http\Controllers\Laralum\BlogsController::update PHP Method

update() public method

public update ( $id, Illuminate\Http\Request $request )
$request Illuminate\Http\Request
    public function update($id, Request $request)
    {
        Laralum::permissionToAccess('laralum.blogs.access');
        # Check permissions
        Laralum::permissionToAccess('laralum.blogs.edit');
        # Check if blog owner
        Laralum::mustOwnBlog($id);
        # Find the blog
        $row = Laralum::blog('id', $id);
        if ($row->user_id == Laralum::loggedInUser()->id or Laralum::loggedInUser()->su) {
            # The user who's trying to modify the post is able to do such because it's the owner or it's su
            # Save the data
            $data_index = 'blogs';
            require 'Data/Edit/Save.php';
            # Return the admin to the blogs page with a success message
            return redirect()->route('Laralum::blogs')->with('success', "The blog has been edited");
        } else {
            #The user is not allowed to delete the blog
            abort(403, trans('laralum.error_not_allowed'));
        }
    }