laravel

Laravel (Echo, Sanctum, websockets) + Pusher + Nuxtjs SPA

你说的曾经没有我的故事 提交于 2021-01-29 07:33:37
问题 I'm trying to send events to private channel, but I can't receive them. Otherwise it works fine for public channels. Here's my code : Plugin : Echo.js window.Echo = new Echo({ broadcaster: 'pusher', key: process.env.MIX_PUSHER_PUBLIC_KEY, wsHost: process.env.VUE_APP_WEBSOCKETS_SERVER , //window.location.hostname,// cluster: process.env.MIX_PUSHER_APP_CLUSTER, wsPort: 6001, forceTLS: false, /* key: process.env.MIX_ABLY_PUBLIC_KEY, wsHost: 'realtime-pusher.ably.io', wsPort: 443, */ disableStats

Laravel routes not working as expected

戏子无情 提交于 2021-01-29 07:26:00
问题 I have just created UserController and added a route in the routes.php file: Route::resource('users', 'UserController'); When I visit laravel.dev/users I expected to see the user index view, but instead I get a 404 error: The requested URL /users was not found on this server. Here is the output when running: php artisan routes +--------+------------------------+---------------+------------------------+----------------+---------------+ | Domain | URI | Name | Action | Before Filters | After

Stripe Api error: Must provide source or customer

北城余情 提交于 2021-01-29 07:16:29
问题 Stack on stripe integration gateway laravel project. After creating controller function for post checkout and checkout.js file i'm facing the above error. It seems to be ok, and i don't know what do. I find some answers about this topic on stackoverflow but the code seems to be ok and i'm very stack on this. Request POST body: { "amount": "11100000", "currency": "usd", "description": "My First Test Charge" } Response body: { "error": { "code": "parameter_missing", "doc_url": "https://stripe

Bootstrap modal: dynamically load value in input field

瘦欲@ 提交于 2021-01-29 07:13:48
问题 I have a Bootstrap modal in a Laravel app that I'm trying to dynamically load. The idea is to fill the input fields in the modal with data coming from my database so I can update the values. I'm almost there.... I have the following in my view file: <a href="#myModal" data-toggle="modal" data-target="#edit-auction-modal" data-id="1" data-title="title 1" type="button" class="btn btn-sm btn-primary btn-warning">Open modal</a> The 'data-id' and 'data-title' are passed to a JS function that looks

How to make a Migration file based on a model in Laravel

天大地大妈咪最大 提交于 2021-01-29 07:13:20
问题 What if I have some model, with non-default features (like soft delete or custom id name) and want to create a Migration file from it, which would have all these properties in it? So here is my model: class Test extends Model { use SoftDeletes; protected $primaryKey = 'test_id'; protected $table = 'my_flights'; protected $dates = ['deleted_at']; } And I want my Migration file to be based on it. But when I use command php artisan make:migration create_test(s)_table (I tried both test and tests

Can't run php artisan on ubuntu terminal on windows 10 machine

走远了吗. 提交于 2021-01-29 07:12:01
问题 I am trying to run artisan commands on ubuntu terminal from Windows machine, using Windows terminal and Ubuntu app from Microsoft store. Tried and searched many times but still no progress. I tried steps in this question Laravel PHP Command Not Found as when I am running php artisan .. error shows "Command 'php' not found, but can be installed with:sudo apt install php7.4-cli" also I downloaded laravel globally on my windows machine but when I try to run laravel on ubuntu terminal "/usr/bin

Laravel : how to create unique tag in tags model

我怕爱的太早我们不能终老 提交于 2021-01-29 07:08:54
问题 I want create tag for posts . I don't want tags repetitions to be saved,But it is stored repeated public function store(Request $request) { $data = $request->all(); $post = Post::create($data); if ($post && $post instanceof Post) { $tags = $request->input('tags'); foreach ($tags as $tag){ $newTag = Tag::create(['name'=>$tag]); $tags[] = $newTag->id; } $post->tags()->sync($tags); return redirect()->back(); } } How can it be done? 回答1: updateOrCreate method will help check It will create data

Attach images to product variants when creating a new product Laravel

风格不统一 提交于 2021-01-29 07:07:58
问题 i'm having difficulty attaching images to variants when creating new products. for example a product A with variant A1 color blue size small images img1, img2 variant A2 color blue size medium image img3 img4 when I save this to the database, img1, img2, img3, img4 goes to both variant A1 and A2 instead of each variant to have its own images. How do I solve this? here is my controller public function variants(Request $request) { $data = $request->all(); foreach($data['title'] as $key =>

Laravel Nginx Every Second Request Handle

浪尽此生 提交于 2021-01-29 07:04:08
问题 i want to ask about the request handle The case is, if server receive the same post request or the same key parameter, the request is on hold first or stored until there are no more requests for 5 seconds or a certain condition. and after that the request is processed to the database So from the client site send post every second, but server don't need to process it to the database every second, just the most recent request Has anyone ever known about such needs, using what methods, maybe

Laravel 7 and VueJs Vue Multiselect Noob Question

百般思念 提交于 2021-01-29 07:01:09
问题 I am a totally noob at laravel and npm and vuejs things. I made a new Laravel Project and instead of playing around with jquery I want to learn how to use vuejs. I ran against a wall today :( trying 2 days to get this Multiselect (https://vue-multiselect.js.org/#sub-select-with-search) running on my project. I think I am missing some basics ... What I've done: ran on terminal npm install vue-multiselect created in resources/js/comonents/Multiselect.vue pasted this code in /Multiselect.vue: