Laravel 5.2 attempting to bind data to a partial view - laravel-5

I am using using Laravel 5.2 binding data to a partial view. I receive the following error "Object of class Illuminate\View\View could not be converted to int"
with this code in the appServiceProvider boot method:
// binding data to a partial view
view()->composer('partials.nav', function($view)
{
$view-with('latest', Article::latest()->first());
});
Any thoughts on how I received this error and how I can solve this problem. Any assistance would be greatly appreciated.I'm at the home stretch of these fundamentals :)

replace $view-with with $view->with otherwise it will be interpreted as a minus.

Related

Page redirection is not working from BaseController (Codeigniter 4)

I'm trying to make a separate function checkUser insede BaseController. But page redirection is not working inside this function. Even inside __construction() function this is not working also. But when I use it in initController or any other controller function, then this is working. How can I solve this problem, please guide me.
BaseController (In my case AdminBaseController)
This is Dashboard Controller
Showing this error
As you can see in the CI4 documentation, initController() is called after __construct(). Then, when you call checkUser(), your response object is still not initialized, thus null.
You could move the code of your __construct() method into the initController() method, in your AdminBaseController.

LARAVEL - INPUT ERROR - The POST method is not supported for this route. Supported methods: GET, HEAD

I'm trying to create an input form but couldn't find the solution from the error
This is what it said
My View Code
My Controller
My Router
I've tried some tips online but it still won't work
It's because your route name is not defined. you should add the route name like this
Route::post('CreateItem', 'CreateItem#insert')->name('CreateItem');
I think is related to the route name. Have you check which uri is posting the form? Can you try:
Route::post('/createItem', function () {
//
})->name('createItem');
Sorry, got the answer
Route::post('CreateItem','CreateItem#insert');
to
Route::post('/create_item','CreateItem#insert');
and
class CreateItem extends Controller
in my question, I typed the wrong controller name, it should be CreateItem
Thanks for the effort to answer my question tho..

Trying to get property of non-object error on laravel 5.4

(2/2) ErrorException
Trying to get property of non-object (View: C:\xampp\htdocs\bgcbus\resources\views\usercrud\sendView.blade.php)
Visit `https://pastebin.com/wuV2zzhp` for link of the complete code that I
think that took part on the token sending or verification process.
I want my application to send a verification token to email address of new users(only the admin of the system can add new users)
enter image description here
Welcome to StackOverflow, yobab77! There's a wonderful help article on how to ask questions here, that may help you get better assistance in the future.
ErrorException Trying to get property of non-object (View: C:\xampp\htdocs\bgcbus\resources\views\usercrud\sendView.blade.php)
This error indicates that the bug is coming from your sendView.blade.php view file, which you've stated has the following content:
TO veerify <a href="{{ route('sendEmailDone', ["email" => $user->email,"verifyToken"=>$user->verifyToken]) }}" click here />
The only object being accessed in this view is $user. Let's see if we can figure out why it isn't an object.
Your sendView view is being loaded through the verifyEmail Mailable. When loading a view via a Mailable, its view data can be pulled from the public properties of the Mailable. Your Mailable does have public $user; defined, so it should be sent to the view. So why isn't it an object?
Assuming you've pasted the exact content of your Mailable, there appears to be a typo in your constructor:
public function __construct(User $user)
{
//
$this->userC=$user;
}
This is saving the supplied User object to the public property $userC, not $user.
Hopefully this simple typo is the root of your issue, and fixing it can let you continue developing your application. :) Should that not be the case, please revise your question and add some additional details (again, see that help article for tips!).

Dingo APi error message

I am trying to render my mailable in the browser in order to check the content. However I'm getting this message {"message":"sha1() expects parameter 1 to be string, object given","status_code":500}
My code snippet
I am running Dingo/Api on my page as well an I think it's somehow connected with it.
Can you please give me the suggestion why am I getting this message instead of rendering mailable?
Thank you
We got this to work by assigning the mailable to a var first and then directly calling the render function on it, like so:
$mailable = new YourMailableName();
return $mailable->render();

Laravel 4 - Unable to override getDateFormat()

Can anyone tell me why I get an error saying Trailing Data, whenever I Override this method in my model and alter it in any way?
protected function getDateFormat() {
return 'Y-m-d H:i:s';
}
Any change to the above code breaks my page.
I am following the official documentation here: http://laravel.com/docs/eloquent#timestamps
getDateFormat is purely meant for how date/time fields are stored in the database. You're not meant to modify it for display purposes.
EDIT: Here are some suggestions for custom formatting of your datetime fields if you don't want to call format() everywhere.
Make a presenter class
Add accessor methods like getDateYearAttribute and getDateMonthAttribute
Use Carbon's setToStringFormat method as documented here
Add a HTML macro for formatting dates
Add a blade extension for the same thing
This may not be the same but I would get this error when working with timestamps and carbon but using strtotime() on the data i was passing resolved my issue, may help you.

Resources