laravel-5.3

How to validation number of files

邮差的信 提交于 2019-12-12 03:40:40
问题 How to validation number of files. I find many way and read alot of topic. But i can't found this result. I found only validation files size. 'files' => 'size:2560|max:2560' All of this only files size. How can I know number of files. 回答1: It seems that there is no default rule for the number of files. However, you can write a custom rule for validation. https://laravel.com/docs/5.3/validation#rule-file Please have a look here for a sample on implementation for the same. Limit number of files

Laravel Eloquent duplicate distinct row

我们两清 提交于 2019-12-12 03:29:20
问题 Let's consider the image above. I would like to show duplicated entries as one entry and also I want to show the sum of the " stock " column. In this case it should be 5722. Is it possible to do it using Eloquent? Or what are the best ways to do it? 回答1: Not sure how your database / query is built but you could maybe use something like that: Item::groupBy('item_name') ->selectRaw('*, sum(stock) as sum') ->get(); It will return a collection of Item with an additional “ sum ” field 回答2: This

How to decode base64 in laravel 5.3

本小妞迷上赌 提交于 2019-12-12 02:17:13
问题 i am working on an API for mobile application, from mobile end i'm getting the image in base64 format and inserting it in profile_image column in my database in my web i want to display that image, so how do i decode it <div class="card horizontal card-driver-details"> <div class="card-image card-circular"> <img src="{{ $driver->profile_image}} "> //i want to display here </div> <div class="card-stacked"> <div class="card-content"> <p><b>Name:</b>{{ $driver->first_name }} {{ $driver->last

laravel 5.3 x-editable table bulk is updating, single row in-line is not - Internal server error 500

浪尽此生 提交于 2019-12-12 01:49:19
问题 I have implemented this example by Papadupa verbatum that illustrates bulk editing and row editing (column in line and column pop-up): https://gist.github.com/pupadupa/4b8e8a9a3a466720bad8 The bulk updating works just fine, but the inline row field editing does not, and reports an internal server error (500): jquery.js:8625 localhost:8000/test/update/1 500 (Internal Server Error) x-editable table row edit error Here is papadupa's implementation: Test Table - you do need to add a couple of

Get path to file in storage

只谈情不闲聊 提交于 2019-12-12 01:48:48
问题 I saved a file to storage using: $request->file('avatar')->store('avatars'); Which saved it to: storage/app/avatars/avatar.png How can I get the path to this file/folder ( not the URL)? What is the correct way to do this using Laravel's Filesystem? 回答1: There is no correct way to do this; because it should not be done. The Storage is an opaque system to talk to different storage systems; as such there is no api to get the backing file path. As an example, that wouldn't work with Amazon S3.

L5 How to use trait that hashes id but keep pivot functionality

拈花ヽ惹草 提交于 2019-12-12 01:45:13
问题 I added hashes to my ID's using a trait. However by doing that now I can no longer use attach() or relationships. For example this relationship does not work in my view anymore: @foreach ($invoice->items as $item) {{ $item->item }} @endforeach Here is the trait that hashes the id for me <?php namespace App\Traits; use Hashids\Hashids; use Illuminate\Database\Eloquent\Builder; trait HashedId { /** * Get the user's id as hashids. * * @param $value * @return string */ public function

How to solve error “Uncaught (in promise) TypeError: Cannot create property” ? (vue.js 2)

夙愿已清 提交于 2019-12-12 01:43:29
问题 My code is like this : <!DOCTYPE html> <html> <head> <title>Laravel</title> <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css"> </head> <body> <div class="container"> <div class="col-md-8 col-md-offset-2"> <div id="app"> <ul class="list-group"> <li class="list-group-item" v-for="item in items"> <a href="/item/@{{ item.id }}"> @{{ item.title }} </a> </li> </ul> <nav> <ul class="pagination"> <li v-if="pagination.current_page > 1"> <a href="#" aria-label=

How do I make a referral program in Laravel?

你。 提交于 2019-12-12 01:37:53
问题 I am trying to create a program where other users can sign up using links of other already registered users. So, when one is referred, this is how the url would look like mywebsite.com/register?ref_id=555 // ref_id is existing user id I am using the default Laravel auth. There is a hidden input value which would contain the value of ref_id if it exists. My database has a column called referred_by which is an INT and set to null by default. When someone registers using the link with ref_id,

withCount() doesn't include deleted rows?

谁说胖子不能爱 提交于 2019-12-11 16:47:17
问题 How can I make withCount('comments') also include all deleted/trashed rows? For example, if I have 5 comments, and I delete 1, I still expect withCount('comments') to return 5, but instead it's returning 4. My full query looks something like this: $query = Post::withTrashed() ->withCount('comments') ->get(); 回答1: You can use the withTrashed method: >withTrashed() 回答2: I think you can try this $query = Post::withCount('comments') ->withTrashed() ->get(); OR $query = DB::table('post') ->select(

how can loop all data then save it after check all data in loop

北城余情 提交于 2019-12-11 14:57:14
问题 Now query is already work but if I add multiple id_p it's checking only first loop any idea how to fix this I want to check all id_p $available > 1 then save(); into database $count = count($request->get('quantity_box')); for ($i=0; $i < $count; $i++) { $available = $this->check_stock($id_w, $id_p, $qty); $id_w = $request->input('idw'); $id_p = $request->get('id_p')[$i]; if($available > 0){ echo 'success'; }else{ echo 'error'; } } private function check_stock($idw, $id_p,$qty){ $count = DB: