1. Go to this page and download the library: Download zareismail/flexi library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zareismail / flexi example snippets
useApp\Models\Post;
/**
* Resolve the resource for the incoming request.
*/publicfunctionresolve(FlexiRequest $request){
$this->post = Post::findByUri($request->segment(1));
abort_unless($this->post, 404);
}
namespaceApp\Flexi\Widgets;
useFlexi\Widgets\Widget;
classPostDetailextendsWidget{
/**
* Resolve the widget data.
*/publicfunctionresolve($resource){
$this->post = $resource->post;
}
/**
* Get the evaluated contents of the widget.
*
* @return string
*/publicfunctionrender(){
return view('post', $this->post);
}
}
/**
* Get the widgets available on the entity.
*
* @return array
*/publicfunctionwidgets(Request $request){
return [
PostDetail::make('Post Detail'),
];
}
/**
* Get the widgets available on the entity.
*
* @return array
*/publicfunctionwidgets(Request $request){
return [
PostDetail::make('Post Detail')->canSee(fn ($request) => $request->user()->can('viewPost', $request->resolveResource()->post)),
];
}
bash
php artisan flexi:resource Post
bash
php artisan flexi:widget PostDetail
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.