Category : arrays

I can’t see errors when i try the named error bag. Can someone help me? Thanks. (Laravel 8) Controller $request->validateWithBag(‘contactform’, [ ‘name’ => ‘required’, ’email’ => ‘required|email’, ‘subject’ => ‘required’, ‘message’ => ‘required’, ]); View @if($errors->any()) <div class="uk-alert uk-alert-danger"> <a class="uk-alert-close" uk-close></a> <h3 class="uk-text-light">There was an error while sending contact form.</h3> @foreach($errors->contactform->all() as $error) <p>&mdash; ..

Read more

My laravel json resource is here <?php namespace AppHttpResources; use IlluminateHttpResourcesJsonJsonResource; use AppModelsSurveyResponse; class SurveyQuestionsCollection extends JsonResource { /** * Transform the resource collection into an array. * * @param IlluminateHttpRequest $request * @return array */ public function toArray($request) { if(isset($this->id)) { return [ ‘id’ => $this->id, ‘survey_id’ => $this->survey_id, ‘question’ => $this->question, ‘sequence’ => ..

Read more

I want to send an array (a sort of shopping cart hardcoded) from my Controller to mailable markdown template and loop it in a table component in a way to have several lines containing all my commands. I send this data from my view with a POST request : commande = { "phone":"+213582828193", "email":"[email protected]", "address":"2 ..

Read more

If I enter the wrong url address for example http://127.0.0.1:8000/okec Undefined index: poster_path and not 404 not found <div class="col-sm-2 text-center"> <div class="figure"> @if ($infoFilm[‘poster_path’]) <img class="img-fluid img-thumbnail rounded" src="{{ ‘https://image.tmdb.org/t/p/w185/’.$infoFilm[‘poster_path’] }}" alt="Poster"> @else <img class="img-fluid img-thumbnail rounded" src="https://via.placeholder.com/200×240?text=mUaacH" alt="NoImage"> @endif </div> </div> Controller public function details($id) { $infoFilm = Http::withToken(config(‘services.tmdb.token’)) -> get(config(‘services.tmdb.apiurl’).’movie/’.$id) -> json(); ..

Read more

part of this data in store method decoded and i want to use this encoded data in blade template: How is this possible? public function store(VehiclesRequest $request) { $data = Vehicle::create([ ‘container_type’ => $request->container_type, ‘type’ => $request->type, ‘delivery_capacity’ => $request->delivery_capacity, ‘plate_number’ => json_encode($request->plate_number), ‘chasis_number’ => $request->chasis_number, ‘capacity_dimensions’ => json_encode($request->capacity_dimensions), ‘fuel_consumption_rate’ => $request->fuel_consumption_rate, ‘capacity_weight’ => $request->capacity_weight, ..

Read more

i’d like to save data from multiple select to the database. So a user can choose more than one products in a multiple select. I’ve tried the code like below but i got this error "ErrorException Array to string conversion". Here is my blade.php <div class="form-group row" style="display:none;" id="inputbarang"> <label class="col-form-label col-lg-3 col-sm-12">Barang</label> <div class="col-lg-4 ..

Read more

This is my vuex store file: export const posts = { namespaced: true, state: { currentPost: ”, posts: [], }, mutations: { SET_POSTS(state, posts) { state.posts = posts }, SET_POST(state, post) { state.currentPost = post }, actions: { fetchPosts({commit}) { PostAPI.getPosts() .then(function(response) { commit(‘SET_POSTS’, response.data) }) }, fetchPost({commit}, postId) { PostAPI.getPost(postId) .then(function(response) { commit(‘SET_POST’, response.data); ..

Read more

i have simmilar question to this Laravel nova action – get current model instance on fields() but with info from https://github.com/laravel/nova-issues/issues/1813 It is possible. I use Laravel 7.x and nova 3.10 I have a resource with field "size" for example 3KG, 4KG I have an action with (only on index rows) field "amount" (number field) ..

Read more

I’m having a problem with using a basic shuffle() function in Laravel. It returns the same result, which seems to be changing once every 10 or 20 minutes. Here’s the basic code I’m testing: $ar = [‘a’, ‘b’, ‘c’]; shuffle($ar); var_dump($ar); Log::info(json_encode($ar)); And here’s the log: Sourc..

Read more

MY CODE VS I WANT This is the result of my query date: {2020-09-28: {work_hours: 8}, 2020-09-29: {work_hours: 8}, 2020-10-02: {work_hours: 8},…} 2020-09-28: {work_hours: 8} 2020-09-29: {work_hours: 8} 2020-10-02: {work_hours: 8} This is my vue file.. I do a research and found this Create laravel blade horizontal table view from array we have same issue ..

Read more

MY CODE VS I WANT This is the result of my query date: {2020-09-28: {work_hours: 8}, 2020-09-29: {work_hours: 8}, 2020-10-02: {work_hours: 8},…} 2020-09-28: {work_hours: 8} 2020-09-29: {work_hours: 8} 2020-10-02: {work_hours: 8} This is my vue file.. I do a research and found this Create laravel blade horizontal table view from array we have same issue ..

Read more

from my controller sum is not working public function show($id) { $workers = DB::table(‘workers’) ->select(‘wrk_id’,’f_name’,’m_name’,’l_name’) ; $attendance = DB::table(‘attendance’)->where(‘payroll_daily_id’, $id) ->select(‘attendance.*’,’f_name’,’l_name’,’m_name’,DB::raw(‘SUM(reg_hour)as tots’)) ->rightjoinSub($workers,’worker’, function($join){ $join->on(‘attendance.wrk_id’,’=’,’worker.wrk_id’); }) ->groupBy(‘payroll_attn_id’) ->get(); foreach($attendance as $key){ $fetch[$key->wrk_id][‘wrk_id’] = $key->wrk_id; $fetch[$key->wrk_id][‘f_name’] = $key->f_name; $fetch[$key->wrk_id][‘l_name’] = $key->l_name; $fetch[$key->wrk_id][‘m_name’] = $key->m_name; $fetch[‘s’] = $key->tots; $fetch[$key->wrk_id][‘date’][$key->date][‘work_hours’] = $key->reg_hour; } return $fetch; } this is ..

Read more

I am receiving the data from a form where I am trying to save the data to the database. While saving the first record is saved multiple times. return response()->json($request->all()); JSON { "product_combo_name":"asdfadsf", "product_values":"[{"product_data":{"id":1,"slug":"product-name","sku":"product-code","product_name":"Product Name","category_id":1,"subcategory_id":1,"previewImg":"http://localhost/EcommerceBackend/public//assets/images/product/thumb/Product Name.jpeg","hasVariants":false,"deleted_at":null,"created_at":"2020-09-17T07:17:42.000000Z","updated_at":"2020-09-17T10:54:24.000000Z"},"product_qty":"1","product_price":"100","product_tax":"18","hsn_code":"78877","product_line_total":"118.00"},{"product_data":{"id":1,"slug":"product-name","sku":"product-code","product_name":"Product Name","category_id":1,"subcategory_id":1,"previewImg":"http://localhost/EcommerceBackend/public//assets/images/product/thumb/Product Name.jpeg","hasVariants":false,"deleted_at":null,"created_at":"2020-09-17T07:17:42.000000Z","updated_at":"2020-09-17T10:54:24.000000Z"},"product_qty":"1","product_price":"100","product_tax":"18","hsn_code":"197797","product_line_total":"118.00"}]", "shipping_charges":"123", "total_price":"359.00", "combo_total_price":"124.18", "product_total_price":"236.00", "charge_breakup":"[{"name":"qty","qty":"1","per_unit_price":"1","tax":"18","tax_amount":"0.18","line_total_amount":"1.18"}]" } I am trying to save the product_data as individual value, but ..

Read more