Laravel 5.3 class not found - php

I just upgraded from laravel 5.2 to laravel 5.3
Currently I have troubles with the Mailables.
I always receive the ReflectionException Class not found. The strange thing is that, when I try sending the mail directly (without queuing), no problems occur.
I reviewed the jobs table in my database, as I am using the database queuing driver. But that doesn't seems to be the issue.
Here is the full stacktrace:
in Container.php line 734
at ReflectionClass->__construct('') in Container.php line 734
at Container->build('', array()) in Container.php line 629
at Container->make('', array()) in Application.php line 699
at Application->make('') in Job.php line 83
at Job->resolve('') in Job.php line 149
at Job->failed(object(ReflectionException)) in SyncQueue.php line 168
at SyncQueue->handleFailedJob(object(SyncJob), object(ReflectionException)) in SyncQueue.php line 65
at SyncQueue->handleSyncException(object(SyncJob), object(ReflectionException)) in SyncQueue.php line 46
at SyncQueue->push(object(SendQueuedMailable)) in Mailable.php line 138
at Mailable->queue(object(QueueManager)) in Mailer.php line 211
at Mailer->queue(object(OrderReceived)) in MailableMailer.php line 127
at MailableMailer->queue(object(OrderReceived)) in VisitorController.php line 302
at VisitorController->_flushToDatabase(array('firstName' => 'Jules', 'lastName' => 'test', 'email' => 'demo#gmail.com', 'subscribe' => 'true', 'printTicketsByOrganisation' => 'true', 'tickets' => array(array('priceId' => '5947ed599e6a4e19bba0d9b54cb8a471', 'price' => '15.00', 'category' => 'Standaardprijs', 'seat' => '267', 'amount' => '1'), array('priceId' => '49f91249bff343f09cf1a90b9dd5cc1d', 'price' => '5-5.00', 'category' => 'Kinderen (GRATIS)', 'seat' => '266', 'amount' => '1'))), object(Request)) in VisitorController.php line 261
at VisitorController->ajaxPersist(object(Request))
at call_user_func_array(array(object(VisitorController), 'ajaxPersist'), array(object(Request))) in Controller.php line 52
at Controller->callAction('ajaxPersist', array(object(Request))) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(VisitorController), 'ajaxPersist') in Route.php line 190
at Route->runController() in Route.php line 144
at Route->run(object(Request)) in Router.php line 642
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TicketsAvailable.php line 25
at TicketsAvailable->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TicketsOpen.php line 29
at TicketsOpen->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Router.php line 644
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 618
at Router->dispatchToRoute(object(Request)) in Router.php line 596
at Router->dispatch(object(Request)) in Kernel.php line 263
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 149
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
at Kernel->handle(object(Request)) in index.php line 54
at require_once('/home/jules/sites/tickets/public/index.php') in server.php line 21
My mailable class:
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Event;
use App\Visitor;
use App\Organisation;
class OrderReceived extends Mailable
{
use Queueable, SerializesModels;
private $visitor;
private $event;
private $organisation;
private $bankingCode;
/**
* Create a new message instance.
* #param App\Visitor $visitor The visitor who bought the tickets
* #param App\Event $event The event where the visitor bought tickets from
* #param App\Organisation $organisation The organisation that hosts the event
* #param string $bankingCode The formatted banking code the user should use for payement
* #return void
*/
public function __construct(Visitor $visitor, Event $event, Organisation $organisation, $bankingCode)
{
$this->visitor = $visitor;
$this->event = $event;
$this->organisation = $organisation;
$this->bankingCode;
}
/**
* Build the message.
*
* #return $this
*/
public function build()
{
return $this->view('emails.visitor.payementRequestEmail')
->subject(trans('messages.emailPayementRequest'))
->with([
'langCode' => \App::getLocale(),
'eventName' => $this->event->name,
'organisationName' => $this->organisation->name,
'name' => $this->visitor->firstName.' '.$this->visitor->lastName,
'bankAccount' => chunk_split($this->organisation->bankAccount,4,' '),//format to ISO 13616
'bankingCode' => $this->bankingCode,
'url' => $this->organisation->url,
'color' => $this->organisation->colorAsHex,
'ticketAmount' => $this->visitor->seats()->count(),
'totalPrice' => $this->visitor->calculateTotalPrice(),
'email' => $this->organisation->email,
'userEmail' => $this->visitor->email,
'printedByOrganisation' => $this->visitor->printTicketsByOrganisation,
]);
}
}
And finally, the call to send the e-mail:
Mail::to($visitor->email)->queue(new OrderReceived($visitor, $event, $event->organisation()->first(), $humanBankingCode));
What am I doing wrong? Or is this a bug in Laravel?

After configuring the mail settings in config/mail.php, use the Mail class in your controller and place the below code
use Illuminate\Support\Facades\Mail;
or
use Mail;
Then execute the code. Its working fine for me.

Related

ErrorException in HasAttributes.php / Illegal offset type

i have problem in storing data of users ,when user sign up i store half of info in table user and other half in another table ,when hit register butttom i get that error i found that in table user info is stored correctley but in other table nothing is saved.
error
in HasAttributes.php line 818
at HandleExceptions->handleError(2, 'Illegal offset type', 'C:\\wamp\\www\\Menoon1\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Concerns\\HasAttributes.php', 818, array()) in HasAttributes.php line 818
at Model->getCasts() in HasAttributes.php line 803
at Model->hasCast('email', array('date', 'datetime')) in HasAttributes.php line 832
at Model->isDateCastable('email') in HasAttributes.php line 565
at Model->isDateAttribute('email') in HasAttributes.php line 525
at Model->setAttribute('email', 'dde#hg.com') in Model.php line 223
at Model->fill(array('email' => 'dde#hg.com')) in Model.php line 145
at Model->__construct(array('email' => 'dde#hg.com')) in Model.php line 268
at Model->newInstance(array('email' => 'dde#hg.com')) in Builder.php line 1030
at Builder->newModelInstance(array('email' => 'dde#hg.com')) in Builder.php line 723
at Builder->create(array('email' => 'dde#hg.com')) in Model.php line 1332
at Model->__call('create', array(array('email' => 'dde#hg.com'))) in Model.php line 1344
at user_emails->create(array('email' => 'dde#hg.com')) in Model.php line 1344
at Model::__callStatic('create', array(array('email' => 'dde#hg.com'))) in RegisterController.php line 94
at user_emails::create(array('email' => 'dde#hg.com')) in RegisterController.php line 94
at RegisterController->create(array('_token' => 'FZqd7Sc3fQRzmaQ0ImXYebzltzkygJsbKpNcZhv4', 'username' => 'vbnm v bnmm', 'email' => 'dde#hg.com', 'password' => '1111111', 'password_confirmation' => '1111111', 'fname' => 'vbn', 'lname' => 'bnm', 'address' => 'bnm', 'membership' => 'Normal', 'pic' => object(UploadedFile))) in RegistersUsers.php line 33
at RegisterController->register(object(Request))
at call_user_func_array(array(object(RegisterController), 'register'), array(object(Request))) in Controller.php line 55
at Controller->callAction('register', array(object(Request))) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(RegisterController), 'register') in Route.php line 204
at Route->runController() in Route.php line 160
at Route->run() in Router.php line 559
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in RedirectIfAuthenticated.php line 24
at RedirectIfAuthenticated->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Router.php line 561
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 520
at Router->dispatchToRoute(object(Request)) in Router.php line 498
at Router->dispatch(object(Request)) in Kernel.php line 174
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30
at TransformsRequest->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30
at TransformsRequest->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ValidatePostSize.php line 27
at ValidatePostSize->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Kernel.php line 149
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
at Kernel->handle(object(Request)) in index.php line 54
at require_once('C:\\wamp\\www\\Menoon1\\public\\index.php') in server.php line 21
user mode
public function useremail()
{
return $this->hasOne('App\user_emails');
}
other table code
public function user()
{
return $this->belongsTo('App\User');
}
code in registercontroller
protected function create(array $data)
{
$fileName = 'null';
Input::file('pic')->store('avatars');
if (Input::file('pic')->isValid()) {
$destinationPath = public_path('uploads/files');
$extension = Input::file('pic')->getClientOriginalExtension();
$fileName = uniqid().'.'.$extension;
Input::file('pic')->move($destinationPath, $fileName);
}
$user= User::create([
'fname' => $data['fname'],
'lname' => $data['lname'],
'address' => $data['address'],
'username' => $data['username'],
'membership' => $data['membership'],
'pic'=>$fileName,
'password' => bcrypt($data['password']),
]);
$useremail=user_emails::create(['email'=>$data['email']]);
// dd($useremail);
$user->useremail()->save($useremail);
return $user;
}
I dont know your model, but if has composite keys, collection cannot get attributes
Try
$user->useremail()->save(new UserEmail(['email'=>$data['email']]));
Given that the model of the useremail is UserEmail.
And your models are mixed up: it should be for App\UserEmail:
public function user()
{
return $this->belongsTo('App\User');
}
and for App\User
public function userEmail()
{
return $this->hasOne('App\user_emails');
}
Notice the convention, for your own good. 'useremail' becomes userEmail'. The model files become User.php and UserEmail.php. Your tables 'users' and 'user_emails' respectively. As thus, the relationship in 'user_emails' should be 'user_id'. And done.
I faced the same issue, it happened because in the Model I defined also a primary key, but it was already set in the database with a clause when the table was created.

Trying to get property of non-object laravel bogardo/mailgun/src/http/response

This error appears when I try to send email with mailgun package for laravel (bogardo/mailgun).
Route:
Route::post('mail-list/send/{type}/{id}', ['uses' => 'MailingList\MailingListController#sendSiteNews', 'as' => 'mail-list.send']);
Controller MailingListController
use Bogardo\Mailgun\Mail\Message;
use Mailgun;
Controller method:
public function sendSiteNews($type, $id) {
$data = [];
Mailgun::send('email.batch-news', $data, function (Message $message) {
$message->to('foo#example.com', 'John Smith')->subject('Welcome!');
});
];
At first I've tried batch sending. Result was the same. After that I've tried to send simple message like above.
view email.batch-news contains only text with h1 tag.
Error message:
ErrorException in Response.php line 35:
Trying to get property of non-object
in Response.php line 35
at HandleExceptions->handleError(8, 'Trying to get property of non-object', 'D:\\wamp\\www\\asiacrochet\\vendor\\bogardo\\mailgun\\src\\Http\\Response.php', 35, array('response' => object(stdClass))) in Response.php line 35
at Response->__construct(object(stdClass)) in Mailer.php line 68
at Mailer->send('email.batch-news', array(), object(Closure)) in Service.php line 59
at Service->send('email.batch-news', array(), object(Closure)) in Facade.php line 221
at Facade::__callStatic('send', array('email.batch-news', array(), object(Closure))) in MailingListController.php line 67
at MailingListController->sendSiteNews('Lesson', '10')
at call_user_func_array(array(object(MailingListController), 'sendSiteNews'), array('Lesson', '10')) in Controller.php line 55
at Controller->callAction('sendSiteNews', array('Lesson', '10')) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(MailingListController), 'sendSiteNews') in Route.php line 203
at Route->runController() in Route.php line 160
at Route->run() in Router.php line 559
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in HasRole.php line 24
at HasRole->handle(object(Request), object(Closure), 'administrator') in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Authenticate.php line 43
at Authenticate->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Router.php line 561
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 520
at Router->dispatchToRoute(object(Request)) in Router.php line 498
at Router->dispatch(object(Request)) in Kernel.php line 174
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30
at TransformsRequest->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30
at TransformsRequest->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 47
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Kernel.php line 149
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
at Kernel->handle(object(Request)) in index.php line 53
That is method of package:
public function __construct(stdClass $response)
{dd($response->http_response_body);
$this->status = $response->http_response_code;
$this->message = $response->http_response_body->message;
$this->id = property_exists($response->http_response_body, 'id') ? $response->http_response_body->id : '';
$this->data = null;
}
dd($response->http_response_body);
gives only that string value "Mailgun Magnificent API".
So that is the problem.
Check your send-domain "email.batch-news". If this is incorrect mailgun, does identify the API method you are calling.

Laravel unique validation class Class Dokter does not exist

i have some problem with unique validation laravel
<?php
namespace Amodules\Hmastermedis\Http\Controllers;
use Illuminate\Http\Request;
use Amodules\Hmastermedis\Models\Dokter;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Theme;
use Amodules\Hmastermedis\Models\Spesialisasi;
use Yajra\Datatables\Facades\Datatables;
use DB;
use Session;
use validate;
class DokterController extends Controller
{
public function store(Request $request)
{
$this->validate($request, [
'dr_cd' => 'required|unique:Dokter',
'dr_nm' => 'required',
]);
$dokter = new Dokter();
$dokter->dr_cd=$request->dr_cd;
$dokter->dr_nm=$request->dr_nm;
$dokter->spesialis_cd=$request->spesialis_cd;
$dokter->save();
Session::flash('dokter', 'Dokter berhasil di tambahkan');
return redirect('hmastermedis/dokter');
}
}
and this my model
<?php
namespace Amodules\Hmastermedis\Models;
use Illuminate\Database\Eloquent\Model;
/**
*
*/
class Dokter extends Model
{
public $primarykey = 'dr_cd';
public $incrementing = false;
protected $fillable = ['dr_cd','dr_cm','spesialis_cd','paramedis_tp'];
protected $table = 'trx_dokter';
public $timestamps = false;
public function spesialisasi()
{
return $this->hasOne('Amodules\Hmastermedis\Models\Spesialisasi','spesialis_cd','spesialis_cd');
}
}
but when i run my code, class dokter does not exist
Whoops, looks like something went wrong.
1/1 ReflectionException in IlluminateRegistry.php line 334: Class Dokter does not exist
in IlluminateRegistry.php line 334
at ReflectionClass->__construct('Dokter') in IlluminateRegistry.php line 334
at IlluminateRegistry->getManagerForClass('Dokter') in DoctrinePresenceVerifier.php line 123
at DoctrinePresenceVerifier->getEntityManager('Dokter') in DoctrinePresenceVerifier.php line 92
at DoctrinePresenceVerifier->select('Dokter') in DoctrinePresenceVerifier.php line 45
at DoctrinePresenceVerifier->getCount('Dokter', 'dr_cd', 'df', null, null, array()) in Validator.php line 1426
at Validator->validateUnique('dr_cd', 'df', array('Dokter'), object(Validator)) in Validator.php line 545
at Validator->validateAttribute('dr_cd', 'unique:Dokter') in Validator.php line 461
at Validator->passes() in Validator.php line 486
at Validator->fails() in ValidatesRequests.php line 54
at Controller->validate(object(Request), array('dr_cd' => 'required|unique:Dokter', 'dr_nm' => 'required')) in DokterController.php line 60
at DokterController->store(object(Request))
at call_user_func_array(array(object(DokterController), 'store'), array(object(Request))) in Controller.php line 55
at Controller->callAction('store', array(object(Request))) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(DokterController), 'store') in Route.php line 190
at Route->runController() in Route.php line 144
at Route->run(object(Request)) in Router.php line 642
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Router.php line 644
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 618
at Router->dispatchToRoute(object(Request)) in Router.php line 596
at Router->dispatch(object(Request)) in Kernel.php line 267
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 149
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
at Kernel->handle(object(Request)) in index.php line 54
at require_once('D:\xampp\htdocs\amteklab\AMHES\public\index.php') in server.php line 21
thanks four your help
If your model class was created after the controller you are calling it from you need to run composer dump-autoload so that the Dokter is added to the project's autoload_classmap.php

Request validation error on production, not on local

So i've search the farthest reaches of the internet and come up with nothing. Please help!
I am developing locally on my Mac, all is fine.
When I push the site to production (CentOS7 VPS) I get the following error:
BadMethodCallException in Validator.php line 3162:
Method [validatePublication] does not exist.
Here is my app/Services/Validation/CustomValidation.php
```
use Illuminate\Validation\Validator;
class CustomValidation extends Validator {
//added only for test
public function validateCartRow($attribute, $value, $parameters)
{
$valid = (is_null(\Cart::get($value))) ? false : true;
return $valid;
}
public function validatePublication($attribute, $value, $parameters)
{
$valid = (\PublisherAPI::publicationByID($value) == false) ? false : true;
return $valid;
}
}
```
Here is my app/Providers/ValidationServiceProvider.php
```
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\Services\Validation\CustomValidation;
use Illuminate\Validation\Validator;
class ValidationServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* #return void
*/
public function boot()
{
$this->app->validator->resolver(function($translator, $data, $rules, $messages)
{
return new \App\Services\Validation\CustomValidation($translator, $data, $rules, $messages);
});
}
/**
* Register the application services.
*
* #return void
*/
public function register()
{
//
}
}
```
Here is my app/Http/Requests/Cart/addToCartRequest.php
```
namespace App\Http\Requests\Cart;
use App\Http\Requests\Request;
class addToCartRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* #return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* #return array
*/
public function rules()
{
return [
'row_publication_id' => 'required|string|numeric|publication',
'row_price_key' => 'required|string|numeric',
];
}
}
```
This is the request that is failing on production. Again, I stress this is not a problem on my local Mac.
Any thoughts? I'm stumped...
Thanks!
UPDATE: Stack trace...
in Validator.php line 3265
at Validator->__call('validatePublication', array('row_publication_id', '4', array(), object(Validator))) in Validator.php line 485
at Validator->validatePublication('row_publication_id', '4', array(), object(Validator)) in Validator.php line 485
at Validator->validate('row_publication_id', 'publication') in Validator.php line 425
at Validator->passes() in ValidatesWhenResolvedTrait.php line 24
at FormRequest->validate() in FoundationServiceProvider.php line 41
at FoundationServiceProvider->Illuminate\Foundation\Providers\{closure}(object(addToCartRequest), object(Application)) in Container.php line 1031
at Container->fireCallbackArray(object(addToCartRequest), array(object(Closure))) in Container.php line 996
at Container->fireResolvingCallbacks('App\Http\Requests\Cart\addToCartRequest', object(addToCartRequest)) in Container.php line 648
at Container->make('App\Http\Requests\Cart\addToCartRequest', array()) in Application.php line 697
at Application->make('App\Http\Requests\Cart\addToCartRequest') in RouteDependencyResolverTrait.php line 85
at ControllerDispatcher->transformDependency(object(ReflectionParameter), array(), array()) in RouteDependencyResolverTrait.php line 59
at ControllerDispatcher->resolveMethodDependencies(array(), object(ReflectionMethod)) in RouteDependencyResolverTrait.php line 42
at ControllerDispatcher->resolveClassMethodDependencies(array(), object(CartController), 'addToCart') in ControllerDispatcher.php line 144
at ControllerDispatcher->call(object(CartController), object(Route), 'addToCart') in ControllerDispatcher.php line 94
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96
at ControllerDispatcher->callWithinStack(object(CartController), object(Route), object(Request), 'addToCart') in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\Cart\CartController', 'addToCart') in Route.php line 174
at Route->runController(object(Request)) in Route.php line 140
at Route->run(object(Request)) in Router.php line 724
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SessionTimeout.php line 58
at SessionTimeout->handle(object(Request), object(Closure))
at call_user_func_array(array(object(SessionTimeout), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 726
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 699
at Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 54
Turns out it was a filename in app.php when registering the service provider.
I missed it as on local, the filename was correct. However I have a merge-driver setup that I completely forgot about preventing app.php being merged with staging (because of the application URL), so the error persisted.
I think I need to move the application URL to an environment variable and load the relevant config, getting rid of the merge driver.
Thanks to the guys at Laracasts for helping me get to the bottom of this..
https://laracasts.com/discuss/channels/laravel/error-on-production-not-on-local

Laravel 5 Routing Issue - Bad Method Call Exception

I'm attempting to simply send a 'PUT' request to one of my routes (which is called as a resource in the route file), yet I recieve this traceback as the response.
Whoops, looks like something went wrong.
1/1 BadMethodCallException in Controller.php line 273: Method [show] does not exist.
in Controller.php line 273
at Controller->__call('show', array('1'))
at AccountControllerV2->show('1')
at call_user_func_array(array(object(AccountControllerV2), 'show'), array('account' => '1')) in Controller.php line 246
at Controller->callAction('show', array('account' => '1')) in ControllerDispatcher.php line 162
at ControllerDispatcher->call(object(AccountControllerV2), object(Route), 'show') in ControllerDispatcher.php line 107
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 108
at ControllerDispatcher->callWithinStack(object(AccountControllerV2), object(Route), object(Request), 'show') in ControllerDispatcher.php line 67
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\API\V2\AccountControllerV2', 'show') in Route.php line 198
at Route->runWithCustomDispatcher(object(Request)) in Route.php line 131
at Route->run(object(Request)) in Router.php line 692
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Authenticate.php line 47
at Authenticate->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in Router.php line 694
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 661
at Router->dispatchToRoute(object(Request)) in Router.php line 619
at Router->dispatch(object(Request)) in Kernel.php line 214
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in HttpsProtocol.php line 15
at HttpsProtocol->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 55
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 61
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 36
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 40
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in Kernel.php line 115
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 84
at Kernel->handle(object(Request)) in index.php line 53
I cannot for the life of me figure out why this is happening.
Here is a code snippet from the Controller itself (which extends BaseController):
/**
* Update the currently logged User in storage.
*
* #return Response 201
* #return jsonArray account
* #return string message
*/
public function update($account_id) {
$input = Input::all();
$message = 'Account Successfully Updated';
$user = Auth::User();
And here is the Route declaration:
Route::group(array('prefix' => 'api/v2', 'namespace' => 'API\V2', 'middleware' => 'auth'), function()
{
Route::resource('challenges', 'ChallengeControllerV2', ['only'=> ['index','store','update','destroy']]);
Route::resource('groups', 'GroupControllerV2');
Route::resource('account', 'AccountControllerV2');
The call is being made to the correct path. Any ideas why I'm getting what seems to be an illogical response? There is no additional middleware/filters attached to the controller than what is shown.
It turns out that in Laravel 5 if you do not specify the resources available on a Route it will assume that they are all there (unlike in Laravel 4 where it checks to see what resources are available in all controllers). So I had to change the line like so.
Route::resource('account', 'AccountControllerV2', ['only'=> ['index','update','destroy']]);

Categories