I'm trying to create a package that wraps around the View engine and allow the Magic method chaining with Laravel's own methods
Hi!
I'm currently working on a Theme package to allow the users to switch themes easily and dynamically, as such it is supposed to eliminate the user's need to use the View() function on their own, the package is going to handle that by wrapping around it.
My issue presently is; I cannot seem to figure out how to allow this to happen, whenever I'm performing the regular method chaining that I'm used to do with View() on the Theme function that wraps around it, it will not pass through.
How in the world am I supposed to achieve the regular "Magic Methods" (such as withErrors and the likes) dynamically without having to manually add each and every method of this sort to the Theme package's code?
This one kind of seems tricky to me :(
Example of my HomeController, trying to achieve the desired method Chaining with a With() chained method, same should be possible with, say - withErrors() or anything else.
I want every chained method that's supported by the native Laravel's View() method, to be supported by my package's Make() method.
<?php
namespace App\Http\Controllers\Pages;
use.............;
class HomeController extends Controller
{
/**
* Show the Homepage.
*
* @return \Illuminate\Http\Response
*/
public function show()
{
.............
return app('theme')->make('pages.home')->with(compact('news'));
}
}
Doesn't allow me to chain same methods as View() does, trying to figure out a way of making this supported dynamically.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire