laravel

Converting an array of arrays from Laravel's collection into an object with an array in json

左心房为你撑大大i 提交于 2021-02-10 12:06:42
问题 I am generating an an array of categories and subcategories in my Laravel API for use in my client side app. I'm doing this by using the collection's filter and map methods to organize the data pulled from the database: // get the data from the category table $categoryData = $categories->all()->categories(); // filter the data by category names we know we want and create the multi-dimensional array of the fields we need $categoryList = $categoryData->filter(function ($value) { return $value[

Display in VIEW of One to One relation in Laravel Relationship

白昼怎懂夜的黑 提交于 2021-02-10 11:52:35
问题 I am here again with a trouble understanding the correct way of doing Laravel Relationships I have this User Model public function concessionaire() { return $this->hasOne('App\Concessionaire', 'meternum', 'meternum'); } and Concessionaire Model public function user() { return $this->belongsTO('App\User', 'meternum', 'meternum'); } But when I try to display it in my view. the concessionaire data fields does not display.. In my Controller I have this $dataUser = User::where('usertype', '=',

Laravel how to store an array in to database

可紊 提交于 2021-02-10 08:34:12
问题 I store data into array[], when i do dd(($request)); i can see the array with the date. Question how i can store it inside the DB? blade <div class="form-group"> <label for="qualifiche">qualifiche:</label> <input type="checkbox" name="array[]" value="uno" > Uno <br> <input type="checkbox" name="array[]" value="due"> Due <br> <input type="checkbox" name="array[]" value="tre"> Tre <br> </div> 回答1: You have two main options: Option 1: first Serialize the array and save it: $arr = serialize(

How to display parent name in Laravel

徘徊边缘 提交于 2021-02-10 07:25:30
问题 I have a departments table in db with id,name, and parent.The parent is the id that corresponds to the parent root.Now i have displayed the id(parent id) but i want to show the name of the department that correspond with this id.I have tried the query at the departmentcontroller ,index function but it gives me this error Illuminate\Database\QueryException SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: 'departments' (SQL: select departments . id , departments .

Having 2 forms on the same page in Laravel?

心已入冬 提交于 2021-02-10 07:12:19
问题 I'm trying to tackle a "two forms on one page" issue with my PHP code, but its turning out to be more tirkcy than I expected, and just isn't behaving in the correct way as I thought it would. For the first form (Login) I'm using this if statement to determine if the message if for the Login. @if(Session::has('message') && Session::get('last_message_for') == 'login') <div class="notification is-{{ Session::get('color') }}"> <i class="fa fa-times"></i>   {{ Session::get('message') }} </div>

Having 2 forms on the same page in Laravel?

陌路散爱 提交于 2021-02-10 07:06:12
问题 I'm trying to tackle a "two forms on one page" issue with my PHP code, but its turning out to be more tirkcy than I expected, and just isn't behaving in the correct way as I thought it would. For the first form (Login) I'm using this if statement to determine if the message if for the Login. @if(Session::has('message') && Session::get('last_message_for') == 'login') <div class="notification is-{{ Session::get('color') }}"> <i class="fa fa-times"></i>   {{ Session::get('message') }} </div>

How to send image from Laravel controller to API Rest [closed]

﹥>﹥吖頭↗ 提交于 2021-02-10 06:59:43
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 13 days ago . Improve this question I need to take an image from storage in Laravel and send it from a Controller to an external API REST. I am using guzzlehttp multipart but the API didn't receive the file, returns file = null 回答1: This is how I did it a few days ago (taking file from Request): For single file:

Workbox: cannot cache all files when build project

一个人想着一个人 提交于 2021-02-10 06:58:19
问题 I use Vuejs and I use workbox-webpack-plugin in order to make my site offline, I want to cache a folder which contains all my files (3 files) like picture below, but when I build my project(using Laravel-mix ). The main.js (which contains everything of Vue) cannot be cached in service-woker.js . I tried some ways to fix that but those didn't work. Does anybody face this issue, do you have any solution, many thanks! ->> 回答1: Why are you dealing it manually? Even though you can cache all static

How to add Cron entries to WAMP localhost in Laravel 5.6

一个人想着一个人 提交于 2021-02-10 06:49:06
问题 I am going to create Task Shedule in laravel 5.6 in my app. I am working with windows 7 os and my localhost is WAMP. in laravel documentation there is add Cron entries to your server as * * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1 but I have not any idea about how to add Cron entries with My wamp localhost. my laravel file is in the desktop name as schoolproject then how can add Cron entries with my wamp? 回答1: For people who run a local WAMP server and

How to get value of input in blade.php

跟風遠走 提交于 2021-02-10 06:33:30
问题 I need to get a value of input to use below, how to do that? I tried to like this but error says Undefined variable: name <div class="col-md-10 col-md-offset-1"> <input id="name" type="text" name="name" /> </div> <div class="col-md-10 col-md-offset-1"> @php $nameValue=$_GET['name']; @endphp <input id="name2" type="text" name="name2" value="{{$nameValue}}" /> </div> 回答1: You have to be aware that your input-values (here "name") ist only available after submitting the form. If you want to