laravel-5.4

laravel 5.4 MethodNotAllowedHttpException in RouteCollection.php (line 251)

こ雲淡風輕ζ 提交于 2019-12-13 02:59:58
问题 I'm an amateur in laravel. I use laravel 5.4. so I want to make process delete without form binding but I have an error message like this. Please tell me how to solving this. route: Route::delete('test/{id}','TestController@destroy'); My Form: <td><button type="button" class="btn"><a href="{{URL::to('coba/test/'.$post->id.'/edit') }}" >Edit</a></button><button type="button" class="btn"><a href="{{ action('TestController@destroy', $post['id']) }}" method="post" >Hapus</a></button>{{ csrf_field

How can i add TrimString Middleware in laravel 5.3?

时间秒杀一切 提交于 2019-12-12 22:47:48
问题 Just came to know that Laravel 5.4 has an awesome feature TrimString , which removes the white spaces from any input. I want this middleware in my 5.3 project, any idea how to do that? I just copied the middleware from GitHub repo of Laravel but it is not working. Thanks 回答1: If you want to use this feature in Laravel 5.3 . Add these two classes into your App\Http\Middleware https://github.com/laravel/framework/blob/5.4/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php https:/

Different output inside modal (Laravel 5.4)

谁说胖子不能爱 提交于 2019-12-12 18:17:24
问题 I have this code in my trips.blade.php. The problem is when my $t->employees is outside the modal, I retrieve all my employees but when I put my $t->employees inside my modal, I can only retrieve 1 Data. I can't figure out any error in this scenario. @foreach($trips as $t) <tr> <td>{{$t->id}}</td> <td>{{$t->dateMilled_trip}}</td> <td>{{$t->ticket->ticketNumber_ticket}}</td> <td>{{$t->truckNumber_trip}}</td> <td>{{$t->finalWeight_trip}}</td> <td> {{$t->employees}} -> Here it shows all the

Call to a member function store() on null - laravel 5.4

醉酒当歌 提交于 2019-12-12 16:17:52
问题 I'm trying to upload an image though everytime I submit it's returning that the store() on null error. I've set the form to enctype="multipart/form-data" which hasn't helped. Can anyone point me in the right direction? Thanks. Function inside the controller public function store(Request $request){ $file = $request->file('imgUpload1')->store('images'); return back(); } Form below: <form action="/imgupload" method="POST" enctype="multipart/form-data"> {{ csrf_field() }} <div class="form-group">

Laravel eloquent get most common value in a database column

孤街醉人 提交于 2019-12-12 14:18:36
问题 From a table animals I have the following values in the animal_name column cat dog cat I want to pull the word cat from that because it is the most popular/common word in that column. How do I do that using laravel eloquent? 回答1: Eloquent: App\Animal::select('name') ->groupBy('name') ->orderByRaw('COUNT(*) DESC') ->limit(1) ->get(); Output: => Illuminate\Database\Eloquent\Collection {#711 all: [ App\Animal {#725 name: "cat", }, ], } Same thing with Query Builder: DB::table('animals') ->select

A two digit month could not be found Data missing in Laravel

时光毁灭记忆、已成空白 提交于 2019-12-12 11:18:00
问题 I'm having a table where I'm storing the data in date format through datepicker. While storing the date I'm doing something like this: $data['schedule'] = Carbon::parse($request->schedule)->toDateTimeString(); then in model I've defined like following: protected $dates = [ 'schedule', 'created_at', 'updated_at', 'deleted_at' ]; Now while retrieving the date I'm using diffForHumans() something like this: $event->schedule = $event->schedule->diffForHumans(); But it is throwing an error like

Laravel - Collection with relations take a lot of time

╄→尐↘猪︶ㄣ 提交于 2019-12-12 09:27:08
问题 We are developing an API with LUMEN. Today we had a confused problem with getting the collection of our "TimeLog"-model. We just wanted to get all time logs with additional informationen from the board model and task model. In one row of time log we had a board_id and a task_id. It is a 1:1 relation on both. This was our first code for getting the whole data. This took a lot of time and sometimes we got a timeout: BillingController.php public function byYear() { $timeLog = TimeLog::get();

Method validate does not exist - Laravel 5.4

隐身守侯 提交于 2019-12-12 08:19:28
问题 I have a very weird problem. When I'm submitting the form, it throws an error with server-side validation. Here is my simple controller: namespace App\Http\Controllers; use Newsletter; use Illuminate\Http\Request; class SubscriptionController extends Controller { public function subscribe(Request $request) { $request->validate([ 'email' => 'required|email', ]); } } Submitting the form gives me: BadMethodCallException Method validate does not exist. it should work according to: https://laravel

multiple prefix with the same route group

牧云@^-^@ 提交于 2019-12-12 07:44:45
问题 im writing a fairly simple website for a school ... this website has news , articles , video clips ... etc the way it works is in the home page we present visitor with some lessons like >math >geography >chemistry user selects 1 on these and website contents changes based on the user selection for example if user selects math he will see news , article , videos about math and so on ... right now this is what im doing (pleas ignore syntax errors) Route::group(['prefix'=>'math'], function () {

Why I can't obtain the complete path of a CSS resource in a blade template?

一曲冷凌霜 提交于 2019-12-12 06:50:26
问题 I am very new in Laravel. I am working on a Laravel 5.4 application and I have the following problem using blade to retrieve the comple URL of a CSS resource. This is my app.blade.php file representing the template of all my views: <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <!--<link href="/css/app.css" rel="stylesheet">--> <!--<link href="{{ URL::asset('css/app.css') }}" rel="stylesheet" type="text/css" >--> <link href="{{ asset('css/app.css') }}"