Skip to content

Instantly share code, notes, and snippets.

@Tjoosten
Last active August 20, 2016 01:41
Show Gist options
  • Save Tjoosten/dba5585ecb22ad6e451f8d0b922a1e67 to your computer and use it in GitHub Desktop.
Save Tjoosten/dba5585ecb22ad6e451f8d0b922a1e67 to your computer and use it in GitHub Desktop.
<?php
/**
* Insert a new permission(s).
*
* @url POST: /permissions/insert
* @param Requests\PermissionValidator $input
* @return \Illuminate\Http\RedirectResponse
*/
public function insertPermission(Requests\PermissionValidator $input)
{
if (Permissions::create($input->except('_token'))) {
$roles = User::whereIs('admin')->get();
$user = auth()->user();
$user->notify(new InsertPermission());
}
session()->flash('Message', 'Permission has been added');
return redirect()->back();
}
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'read_at' in 'field list' (SQL: insert into `notifications` (`id`, `type`, `data`, `read_at`, `notifiable_id`, `notifiable_type`, `updated_at`, `created_at`) values (071abbf4-13bc-4699-8f03-9c455f2dd966, App\Notifications\InsertPermission, {"employee_id":9,"message":"has inserted a new permission"}, , 9, App\User, 2016-08-20 01:39:39, 2016-08-20 01:39:39))
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
class InsertPermission extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['database'];
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
'employee_id' => auth()->user()->id,
'message' => 'has inserted a new permission'
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment