If you’ve seen issue 786 on laravel/nova-issues on Github or attempted to add custom buttons to Resources in Laravel Nova you are probably frustrated. I spent a whole day trying to figure this out. But it’s a lot simpler than you think! Laravel Nova is powered by Vue.JS a very […]
Автор: editor
Default values for Nova fields
When creating Nova resources or running resource actions, users are always presented with a blank form. All fields are empty and all checkboxes are unchecked. Often there may be values which can be defaulted or prepopulated to save the user time, rather than needing to be reentered every time a […]
How do you log all API calls using Guzzle 6
37 You can use any logger which implements PSR-3 interface with Guzzle 6 I used Monolog as logger and builtin middleware of Guzzle with MessageFormatter in below example. use GuzzleHttp\HandlerStack; use GuzzleHttp\Middleware; use GuzzleHttp\MessageFormatter; use Monolog\Logger; $stack = HandlerStack::create(); $stack->push( Middleware::log( new Logger(‘Logger’), new MessageFormatter(‘{req_body} — {res_body}’) ) ); $client […]
Laravel polymorphic route model binding
ou can use a shared controller for this with some explicit model binding. The following is untested code, it provides the general idea rather than copy and pasteable. Let me know if you run into any issues. Create a new CommentableModel that extends Model Extend Photo and Video from CommentableModel […]
Re-Introducing Eloquent’s Polymorphic Relationships
You’ve probably used different types of relationships between models or database tables, like those commonly seen in Laravel: one-to-one, one-to-many, many-to-many, and has-many-through. But there’s another type of relationship that’s not so common: polymorphic. So what is a polymorphic relationship? A polymorphic relationship is where a model can belong to […]
Laravel Custom Exception Handler Based on Route Group
public function render($request, Exception $e){ if($request->is(‘api/*’)){ return response()->json([ ‘error_message’ => $e->getMessage(), ‘status’ => Response::HTTP_BAD_REQUEST ]); } return parent::render($request, $e); }
Архитектура ПО: разница между архитектурой и проктированием
Многие не знают, в чем состоит разница между архитектурой и проектированием приложения. Даже сами разработчики зачастую не могут разобрать строку кода и могут спутать элементы архитектуры приложения с элементами проектирования. Будучи разработчиком, я бы хотел объяснить эти понятия , а также разницу между проектированием приложения и его архитектурой. Помимо этого, […]
REST: простым языком
(REpresentational State Transfer) — это архитектура, т.е. принципы построения распределенных гипермедиа систем, того что другими словами называется World Wide Web, включая универсальные способы обработки и передачи состояний ресурсов по HTTP Автор идеи и термина Рой Филдинг 2000г. REST на сегодняшний день практически вытеснил все остальные подходы, в том числе дизайн […]
Using WhereHas in Laravel Polymorphic Relations
It seems like once every project I find myself googling «Laravel Polymorphic WhereHas«, combing through one result after another, frustratedly repeating «How do I do this???». While there isn’t a first-party supported solution, I wanted to document what has been working for me, so I don’t have to continue searching […]
SSH into mobylinux (docker for windows)
#based on po75558Manuel Patrone comment on https://forums.docker.com/t/how-can-i-ssh-into-the-betas-mobylinuxvm/10991/8 #get a privileged container with access to Docker daemon docker run —privileged -it —rm -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker alpine sh #run a container with full root access to MobyLinuxVM and no seccomp profile (so you can mount stuff) docker run —net=host —ipc=host —uts=host […]