laravel-5.2

Writing JSON data to a JSON file

无人久伴 提交于 2019-12-12 05:07:29
问题 Hello in my application I am currently trying to create my own custom log files in .json format. Reason for this is because I want a well structured and accurate log file which can be easily read and would not depend on some special code in my application to read the data. I have been able to create a json file: activities.json I have been able to write and append to that file using File::append($path, $json) This is a sample of the file contents: {"controller":"TestController","function":

I'm getting a MethodNotAllowedHttpException in RouteCollection.php when trying to submit a form using jQuery and ajax

倾然丶 夕夏残阳落幕 提交于 2019-12-12 04:59:25
问题 As mentioned in the subject I'm getting a MethodNotAllowedHttpException in RouteCollection.php when trying to submit a form using jQuery and ajax I've tried the following in my routes.php file Route::post('/send/', 'CommsController@send'); and Route::patch('/send/', 'CommsController@send'); Controller use App\Http\Controllers\Controller; class CommsController extends Controller { protected function send(Request $request); { return response($request); } } jQuery ajax if ( isValid ) { $( "

\Auth::user() is null in 5.3.6?

亡梦爱人 提交于 2019-12-12 04:58:47
问题 This is about Laravel 5.3.6 I am able to login successfully and I can check Auth User after login. I can show the exact location where Auth::guard() has current user object. Below are the details. Go to Login Controller Go to AuthenticatesUsers Trait Go to sendLoginResponse method. User reaches here successfully because user is authenticated successfully. here I can check $this->guard()->user() has current user value. But when control reaches to Role controller....I tried to access it like

Pass user id in laravel after logged in

∥☆過路亽.° 提交于 2019-12-12 04:44:06
问题 I would like to pass / submit the user_id of the currently logged on user. How will I do it in laravel 5.2? Please need help I am not sure on my code on how will I use Auth:user() blah blah. Need help with this. I am new to this. 回答1: You can use the login functionality like this and pass the datas to the required pages as per your wish. public function Dologin() { // create our user data for the authentication $userdata = array( 'email' => Input::get('email'), 'password' => Input::get(

How to access pdf file from storage directly from browser?

三世轮回 提交于 2019-12-12 04:07:04
问题 I want to access a pdf file from the browser, the file is located in laravel storage folder. I don't want the storage to be public. I don't want to download it(that I managed to do it). I simply want to have a get route, and to show that file in the browser like: www.test.com/admin/showPDF/123/123_321.pdf. 123 is an id. If I use: storage_path('app/'.$type.'/'.$fileName); or Storage::url('app/'.$type.'/'.$fileName); return the full server path. thanks. 回答1: Add new route to get pdf Route::get(

Laravel 5 Pass and get a flash data not working

送分小仙女□ 提交于 2019-12-12 03:55:17
问题 i want to pass a flash data from store function to add function but i cant get it to work, i always get null; here is my controller public function add() { return view('cars.add'); } public function store(CarFormRequest $request) { $car = new Cars(array( 'name' => $request->get('name'), 'color_id' => $request->get('color') )); $car->save(); $car->position_id = $car->id; $car->save(); return redirect('/cars/add')->with('status', 'A Car has been added'); } here is my view: @if (session('status'

laravel 5.2 valid ajax request

喜欢而已 提交于 2019-12-12 03:54:50
问题 How can we check in Laravel 5.2 if a request is a valid ajax request. In codeigniter ,we could check it like $this->input->is_ajax_request(). Does, Laravel 5.2 has something similar? Also, I would like to know that how can we validate a request for csrf token. Is it fine if I let my webpage render through the 'web' middleware generating a csrf token and then pass this token as ajax request parameter? Would Laravel take care of validating the token or is there an alternate way around this? I

Form action not working in laravel

对着背影说爱祢 提交于 2019-12-12 03:51:28
问题 I want to insert data in database. i found a problem. I have 2 blade.php page. 1. dashboard.blade.php and another is class.blade.php. When i use in my form action dashboard.blade.php its working. but when i used in action class.blade.php its not working. i can't found this problem. Here is my form action : <form class="form-horizontal" role="form" method="POST" action="{{ url('/dashboard') }}"> {!! csrf_field() !!} when i changed it <form class="form-horizontal" role="form" method="POST"

Laravel 5 Has One Relationship with Form Binding

早过忘川 提交于 2019-12-12 03:50:00
问题 I have spent a pretty good two days on something so simple and small. I have a model called User which has one user note relationship. On the User model's side I have a belongsTo relationship defined and then the user's model defines a hasOne side of relationship. The form I am using binds to $user model meanwhile the UserNote model has its own table that maps to the user with user_id. I have been trying to get what is shown below right; {{ Form::textarea($user->notes, null , [ 'class' =>

Laravel groupBy Database query Builder not working

末鹿安然 提交于 2019-12-12 03:44:46
问题 I have this problem in a query using laravel groupBy, it simply return a groupBy error. I have read the documentation about this but can't really figure it out. I also read the same problem pointing that it is because of postgreSQL that I need to include all the columns in grouBy clause. I tried it but still it doesn't return the distinct values. Please help me with this. Below is my code. Thanks a lot. Controller function public function index(){ $purchases = Purchase::groupBy('purchase