laravel-5.5

Laravel 5.5 On demand notification with slack

耗尽温柔 提交于 2019-12-23 10:33:51
问题 According to this page, we can send a notification on demand without going through a model. How do I do the same using slack? I want to do something like this: $emailAddress = 'my email address'; Notification::route('mail', $emailAddress) ->route('slack', 'what do I put here?') ->notify(new TestNotification()); The code works without the slack line. Edit: this StackOverflow question uses the on demand method 回答1: You should you put the Slack Webhook URL. See: https://laravel.com/docs/5.5

Required field only if another field has a value, must be empty otherwise

江枫思渺然 提交于 2019-12-23 10:17:36
问题 My question is about Laravel validation rules. I have two inputs a and b . a is a select input with three possible values: x , y and z . I want to write this rule: b must have a value only if a values is x . And b must be empty otherwise. Is there a way to write such a rule? I tried required_with , required_without but it seems it can not cover my case. In other words, if the previous explanation was not clear enough: If a == x , b must have a value. If a != x , b must be empty. 回答1: You have

laravel: function in model must return a relationship instance

你离开我真会死。 提交于 2019-12-23 06:44:13
问题 I try to build a path for a model on laravel I created a function in my model: public function path() { return App\Helper\GeneralController::getURL($this); } with dd(App\Helper\GeneralController::getURL($this)) test I got the right answer. (output is a URL) but in view with the call: $article->path I get this error: App\Article:: path must return a relationship instance. What is wrong? 回答1: You need to call it: $article->path() When you do $article->path , you're trying to use Eloquent

Laravel bulk insert many entries with same form

感情迁移 提交于 2019-12-23 05:35:15
问题 My goal is to insert many records at the same time with the same form. I already created a function in the form element that will duplicate all the fields and pass all the data with one submit button. So theres no problem with the view and the data being passed to the controller. I have an array of: array:8 [▼ "_token" => "XLQVP4Hbm85SlZDFa6OnjK0LCoMOsrfs8jGCUwMj" "id" => null "client_id" => array:2 [▼ 0 => "1" 1 => "1" ] "sample_code" => array:2 [▼ 0 => "sadasdas" 1 => "qwewqewqeqweq" ]

Soft deleting in pivot with sync method laravel

别等时光非礼了梦想. 提交于 2019-12-22 08:59:44
问题 I want sync some relation in User's Table and I don't want to Laravel delete the row, I want make some updates on that row (Like fill the deleted_at), I searched so far and only solution i found is that to override sync method. So how i can override the sync method to update the row? Or whats another solution for this problem? EDITED: I know the problem is with detach method, If i could override the detach It will be solved! Thanks 回答1: I think you were looking for this method. $user->your

how to change api_token column in token guard

巧了我就是萌 提交于 2019-12-22 08:18:43
问题 Laravel 5.5 I want to change direction of api token that used in TokenGaurd so, i created a custom guard named CafeTokenGaurd extends TokenGuard, i define __construct function into it like what i want, something like this: public function __construct(UserProvider $provider, Request $request) { parent::__construct($provider, $request); $this->inputKey = 'api_key'; // I want changing this part $this->storageKey = 'api_key'; } Now i want to define api_key from relation with users table like this

Laravel optional prefix routes with regexp

核能气质少年 提交于 2019-12-22 08:15:12
问题 Is there a way to create routes with prefixes so I can have routes like this /articles.html -> goes to listing Controller in default language /en/articles.html -> goes to the same controller /fr/articles.html -> goes to the same controller My current problem is that by doing: Route::group(['prefix=>'/{$lang?}/',function(){}); a route like this: /authors/author-100.html will match a prefix 'authors` , and for sure there is no language called "authors". I use laravel 5.5 回答1: This should be

How to edit the view of “The page has expired due to inactivity” in Laravel 5.5

爱⌒轻易说出口 提交于 2019-12-22 06:52:38
问题 In Laravel 5.5, When you are using CSRF protection (by default) and you send a post request after long inactivity you'll get this error page (Screenshot). I'm ok with this error however, I need to change the view/text of this error to match my application style and my language for sure. Any Ideas in how to edit this view? 回答1: You can override the default view by placing a 419.blade.php file in the resources/views/errors folder. If you're using an editor with global search capabilities, you

In Laravel 5.5, how to get the Job ID after we dispatch a job to the job queue?

别等时光非礼了梦想. 提交于 2019-12-22 05:23:32
问题 Until Laravel 5.4, the dispatch() method returned the queue job id. $job = (new JobClass())->onQueue('queuename'); $jobId = dispatch($job); dd($jobId); // prints the job id In 5.5, it returns a PendingDispatch object, which does not seem to have a method to retrieve the job id. I've already tried with dispatch_now() , but it executes the job immediately and synchronously, while I want it to be executed in the background. 回答1: After opening an issue at Laravel github, the solution was to use:

Run laravel project in localhost

穿精又带淫゛_ 提交于 2019-12-21 14:58:13
问题 I have installed laravel by composer create-project laravel/laravel –-prefer-dist after this run php artisan serve command to laravel project directory and get this result. Laravel development server started: http://127.0.0.1:8000 But when i go to http://127.0.0.1:8000 in browser laravel project not running and give error This site can’t be reached 127.0.0.1 refused to connect. but http://localhost/laravel/public/ it is working. Can anyone tell me that what is proper way to run this laravel