laravel

How to use a resource collection toArray and DB (without Eloquent)

断了今生、忘了曾经 提交于 2021-02-11 18:18:17
问题 I have this query (in a repository, without using eloquent) : public function getUsersOfASchool($schoolId, $request) { $query = DB::table('school_users as su') ->join('users as u', 'u.id', 'su.user_id') ->where('su.school_id', $schoolId); $users = $query->paginate(); return $users; } I have this controller : try{ $users = $this->userRepository->getUsersOfASchool($school->id, $request->all()); } catch(\Exception $e) { return response()->json(['message'=>'Bad request '.$e->getMessage()], 400);

Why may not the type of mime be correctly determined?

╄→尐↘猪︶ㄣ 提交于 2021-02-11 18:18:16
问题 please help. I can not understand why my loaded jpeg picture is determined by the wrong mime type correct option must be image/jpeg $mime_types = ['image/bmp', 'image/gif', 'image/jpeg', 'image/png']; Validator::extend('is_image_array', function($attribute, $values, $params, $validator) use ($mime_types) { foreach ($values as $k => $value) { $f = finfo_open(); $result = finfo_buffer($f, base64_decode($value), FILEINFO_MIME_TYPE); dd($f, $value,$result, $mime_types); if ( !in_array($result,

Why may not the type of mime be correctly determined?

让人想犯罪 __ 提交于 2021-02-11 18:17:08
问题 please help. I can not understand why my loaded jpeg picture is determined by the wrong mime type correct option must be image/jpeg $mime_types = ['image/bmp', 'image/gif', 'image/jpeg', 'image/png']; Validator::extend('is_image_array', function($attribute, $values, $params, $validator) use ($mime_types) { foreach ($values as $k => $value) { $f = finfo_open(); $result = finfo_buffer($f, base64_decode($value), FILEINFO_MIME_TYPE); dd($f, $value,$result, $mime_types); if ( !in_array($result,

How to display stackbarchart in table foreach row?

人走茶凉 提交于 2021-02-11 18:17:07
问题 I have table and 5 column and one of the columns has StackBarChart in it. Basicly what i want to do is this. Is there any way to loop chart and display one for each row? I refer to this link but still didn't work below is my code <table class="table"> <tr> <th>Name</th> <th>Total MD</th> <th>Total LR</th> <th>Total LB</th> <th> Graph</th> </tr> @foreach($detail_laka as $laka) </tr> <td>{{$laka->name}}</td> <td>{{$laka->total_md}}</td> <td>{{$laka->total_lb}}</td> <td>{{$laka->total_lr}}</td>

Laravel Multi level relationship in API Resource

巧了我就是萌 提交于 2021-02-11 16:50:16
问题 My problem is, the api resource loading which i really not needed. Look into my Api Resource files //BoxItemResource.php public function toArray($request) { return [ 'box_id'=> $this->box_id, 'item_id'=> $this->item_id, 'item'=> new ItemResource($this->item) ]; } //ItemResource.php public function toArray($request) { return [ 'id' => $this->id, 'shipping_price' => $this->shipping_price, 'condition_id' => $this->condition_id, 'condition' => new ConditionResource($this->condition) ]; } /

Laravel Multi level relationship in API Resource

吃可爱长大的小学妹 提交于 2021-02-11 16:47:24
问题 My problem is, the api resource loading which i really not needed. Look into my Api Resource files //BoxItemResource.php public function toArray($request) { return [ 'box_id'=> $this->box_id, 'item_id'=> $this->item_id, 'item'=> new ItemResource($this->item) ]; } //ItemResource.php public function toArray($request) { return [ 'id' => $this->id, 'shipping_price' => $this->shipping_price, 'condition_id' => $this->condition_id, 'condition' => new ConditionResource($this->condition) ]; } /

Upload image to external webservice/API using Lumen/Laravel and Guzzle 6

狂风中的少年 提交于 2021-02-11 16:35:55
问题 I want to upload an image to a webservice using Lumen + Guzzle 6. The external web service does not accept "base64-encoding" the image to be sent. Only the image file is accepted as such. But I still get an error message from the external webservice/API that the image could not be found or it rather seems to be that Guzzle sent the request without the image. The check with file_exists($filename_with_path) responded successfully, therefore access to the file is generally possible. If I work

Upload image to external webservice/API using Lumen/Laravel and Guzzle 6

萝らか妹 提交于 2021-02-11 16:35:00
问题 I want to upload an image to a webservice using Lumen + Guzzle 6. The external web service does not accept "base64-encoding" the image to be sent. Only the image file is accepted as such. But I still get an error message from the external webservice/API that the image could not be found or it rather seems to be that Guzzle sent the request without the image. The check with file_exists($filename_with_path) responded successfully, therefore access to the file is generally possible. If I work

How to use One Laravel Controller with Multiple Guard instead of Duplicating the Controller

六月ゝ 毕业季﹏ 提交于 2021-02-11 15:42:16
问题 I have two Guards Admin User Also i have created controllers where user can manage his own data and admin can also manage user data. So i created two Controllers Controllers Admin EducatonBackgroundController User EducationBackgroundController In User/EducationBackgroundController i have this function which fetch education background of a current logged user and display on the user view public function index(Education $education) { try { $educations = $education->where('user_id',$this-

How to append or attach a pivot relationship to a model?

穿精又带淫゛_ 提交于 2021-02-11 15:37:33
问题 I am trying to get the practice area record of lawyers from practice_areas table along side each time I get a lawyer's record from lawyer_profiles_table. This two tables (practice_areas and lawyer_profiles) are related with a pivot table named (lawyer_practice_area) This code below are from the LawyerProfile Model public function practice_areas() { return $this->belongsToMany(PracticeArea::class, "lawyer_practice_area", "practice_area_id", "lawyer_id"); } I tried getting it through an