laravel-5.2

Old input for array?

三世轮回 提交于 2020-01-12 15:02:52
问题 I have foreach and inside foreach i have input like this: <input type="text" id="text-title" name="article_title[{{$language->code}}]" value="{{ old('article_title[$language->code]') }}" class="form_input" /> Im trying to add old input like this but its not working. Any suggestion how can i use old for array? Also i tried this but also not working: <input type="text" id="text-title" name="article_title[{{$language->code}}]" value="{{ old('article_title.0') }}" class="form_input" /> I have

Laravel 5.2 filter with dropdownlist

亡梦爱人 提交于 2020-01-11 11:51:49
问题 I want to make drop-down list filtering. I have a web page, that shown some post with title and categories. The page has a drop-down in nav.blade.php . I dynamically generate drop-down from categories table. But when I select an item of drop-down (for example a category name) I want page to show me the posts only of that category. Also I have created the Category and Posts model and set the relationships. I can see all posts on my main page but can't filter content with drop-down list. What I

How to optimize code in Laravel?

倖福魔咒の 提交于 2020-01-11 07:49:09
问题 I use the following code to get data from two related tables: $arr = []; $objectModel = new ProductCategory(); $objectModel::$language = 2; $subcategories = $objectModel::with("translate", "parent")->get(); foreach($subcategories as $key => $item) { $arr[$item->translate()->first()->objectId] = $item->translate()->first()->name; } array_unshift($arr, 'Select category'); return $arr; In result this part of code I get array with key => value to insert this in select list in Blade template. But

Laravel changes created_at on update

浪子不回头ぞ 提交于 2020-01-10 08:23:06
问题 I found this answer on the subject, but it doesn't work for me. So, I make an entry in the database: // Write lead to database $lead = Lead::create($lead_data); And the timestamps look like this, which is good: | 2016-01-08 10:34:15 | 2016-01-08 10:34:15 | But then I make a request to an external server, and I need to update the row: $lead->user_id = $response['user_id']; $lead->broker_id = $response['broker_id']; $lead->save(); and the created_at field gets changed: | 2016-01-08 04:34:17 |

How to call one function inside another function in same controller in laravel 5.2

别等时光非礼了梦想. 提交于 2020-01-07 06:19:07
问题 GetEstimateController.php class GetEstimationController extends Controller { public function fill_dropbox(){ $data = ProcedureTreat::get(['pro_name']); $data1 = HospitalPackage::get(['address']); // return $this->get_estimate(); // dd($data); return View::make('get_quote')->with('address',$data1)->with('procedureName',$data); } public function get_estimate($name,$address){ $data = HospitalPackage::where(['pro' => 'name', 'address' => 'address'])->get(); $Dropbox_fill = $this->fill_dropbox();

laravel upload files in many inputs

混江龙づ霸主 提交于 2020-01-07 04:38:06
问题 I'm trying to upload files in 4 inputs files i get the solution from here but the problem the last file4 input file uploaded in all fields in database in my blade form {!! Form::file('file1', null,['class'=>'form-control']) !!} {!! Form::file('file2', null,['class'=>'form-control']) !!} {!! Form::file('file3', null,['class'=>'form-control']) !!} {!! Form::file('file4', null,['class'=>'form-control']) !!} in my controller $input = $request->all(); $files =[]; if ($request->file('file1'))

BadMethodCallException with message 'Call to undefined method Illuminate\Database\Query\Builder::belongToMany()'

ぐ巨炮叔叔 提交于 2020-01-07 04:30:48
问题 Following the instructions in this laracast : https://laracasts.com/series/laravel-5-fundamentals/episodes/21 I created a Channel model class Channel extends Model { // protected $fillable = [ 'title', 'description', 'published_at', ]; public function scopePublished($query) { $query->where('published_at', '<=', Carbon::now()); } public function setPublishedAtAttribute($date) { $this->attributes['published_at'] = Carbon::createFromFormat('Y-m-d', $date); } /* * Get the tags associated with the

Laravel cache::remember is returing object as an array

北城余情 提交于 2020-01-07 04:20:26
问题 Laravel Cache::remember is returning a LengthAwarePaginator object as an array. function getNotifications( $userID ) { $values = Cache::remember('cache-key', 10, function() { $query = DB::table( 'user_notifications' ) ->leftJoin( 'notifications', 'user_notifications.notification_id', '=', 'notifications.id' ) ->where( 'user_notifications.user_id', $userID ) ->select( 'notifications.*' ) ->orderBy('created_at', 'DESC') ->paginate(5); return $query; }); return $values; } If I dd($query) before

Laravel Relationship in a pivot model

ε祈祈猫儿з 提交于 2020-01-07 02:35:21
问题 I have three tables, one of them is pivot table (and pivot model) and trying to create belongsTo relationship in pivot model (foreign key in pivot table) so that I can get the relevant name from some other table(has primary key). What I want to do is illustrating by images below: Pivot Table is: And other table is: It is pivot Model: class MproductIngredient extends Model { public function qtyType() { return $this->belongsTo('App\TIngredientType','priQuantityTypeNo'); } } How to get the

Laravel 5.2 : How to call “sendFailedLoginResponse” from custom Login Event Handler?

你。 提交于 2020-01-06 23:48:51
问题 In Laravel 5.2, there is a function already overriden in my AuthController.php : public function sendFailedLoginResponse() { $errors = new MessageBag([ 'email' => ['Error message for email'], 'password' => ['Error message for password'], 'mycustominput' => ['Error message for my custom input field'], ]); return redirect()->back()->withErrors($errors); } This alone works (like magic) via normal FAILED login attempts. (When login is failed, the login form already shows this custom error