Illuminate\Database\Eloquent\Model::__construct(): Argument #1 ($attributes) must be of type array, int given, called in C:\xampp\htdocs\luma\app\Http\Controllers\HubungiController.php on line 62
controller :
<?php
namespace App\Http\Controllers;
use auth;
use App\Models\Logo;
use App\Models\User;
use App\Models\Contact;
use App\Models\Logoweb;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Notification;
use App\Notifications\Contact as NotificationsContact;
class HubungiController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return view('home.contact',[
'logo' => Logo::paginate(1),
]);
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('home.contact',[
'contact' => new Contact(),
]);
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$this->validate($request, [
'nama' => 'required'
]);
$contact = Contact::create([
'nama'=> $request->nama,
'subject'=> $request->subject,
'pesan'=> $request->pesan,
'email'=> $request->email,
'hubungi'=> $request->hubungi
]);
$user = User::where('id','!=',auth()->user()->id)->get();
$user_create = auth()->user()->name;
Notification::send($user,new contact($contact->id,$user_create));
return redirect(url('hubungi'));
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
}
App\Notifications
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class Contact extends Notification
{
use Queueable;
private $contact_id;
private $user_created;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($contact_id,$user_created)
{
$this->contact_id = $contact_id;
$this->user_created = $user_created;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['database'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->line('The introduction to the notification.')
->action('Notification Action', url('/'))
->line('Thank you for using our application!');
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
'contact_id' => $this->contact_id,
'user_created' =>$this->user_created,
];
}
}