laravel-5.2

Laravel force delete event on relations

放肆的年华 提交于 2019-12-06 08:59:13
I'm developing a Laravel web app using Laravel 5.2. My question is very simple... How do I listen to a forceDelete event in order to forceDelete model relations? I've been looking around the web and S.O. for a few but all the questions/answers I've found where releted to the delete method, and also in the API documentation I haven't found very much... In my case I have a Registry model and a RegistryDetail model Registry table |id|name|surname|.... RegistryDetail table |id|id_registry|.... I've created for both this boot function: protected static function boot() { parent::boot(); static:

Delete method with Sweet Alert in Laravel

回眸只為那壹抹淺笑 提交于 2019-12-06 08:48:50
I'm testing a method using Sweet Alert, to improve the messages issued by the Javascript alert method with the laravel framework. 1 - I downloaded the files sweetalert.css and sweetalert.min.js. 2 - So I connect the files from app.blade.php <!-- Sweet Alert --> <link href="{{ asset('/dist/css/sweetalert.css') }}" rel="stylesheet"> <!-- Sweet Alert --> <script src="{{ asset('/dist/js/sweetalert.min.js') }}"></script> 3 - I created the delete button using the onclick event of Javascript and the following Sweet Alert function: {!! Form::open(['method' => 'DELETE','route' => ['users.destroy',

View pdf instead of download using PDF js

北战南征 提交于 2019-12-06 08:01:18
In my page, I'm trying to display a thumbnails of my pdf using PDF JS and it works on local, but when I upload my code in my webserver the pdf file is auto download. In my local : Code : $(function() { var filePath = "http://example.com/public/uploads/docs/Document_One_1.pdf"; function Num(num) { var num = num; return function () { return num; } }; function renderPDF(url, canvasContainer, options) { var options = options || { scale: 1.1 }, func, pdfDoc, def = $.Deferred(), promise = $.Deferred().resolve().promise(), width, height, makeRunner = function(func, args) { return function() { return

Registration error in Laravel

本秂侑毒 提交于 2019-12-06 07:31:24
I use the default auth/registration in Laravel 5.3. When I try to register new user I get error: FatalThrowableError in RegistersUsers.php line 33: Call to undefined method Illuminate\Auth\TokenGuard::login() I have made some changes in configuration Laravel: 'defaults' => [ 'guard' => 'api', 'passwords' => 'users', ], So, by default I use api guard The authentication driver api you are trying to use is TokenBased. That means the server will issue your client a Token on successful authentication using credentials. Then, client can present this token to server while making the request to

Sending Audio Blob to server

大兔子大兔子 提交于 2019-12-06 06:34:19
I am trying to send an audio blob produced by WebAudio API and Recorder.js to my Laravel Controller using jQuery's $.post method. Here is what I am trying. $('#save_oralessay_question_btn').click(function(e){ var question_content = $('#question_text_area').val(); var test_id_fr = parseInt($('#test_id_fr').val()); var question_type = parseInt($('#question_type').val()); var rubric_id_fr = $('#rubric_id_fr').val(); var reader = new FileReader(); reader.onload = function(event){ var form_data = new FormData(); form_data.append('audio_data', event.target.result); var result = $.post('../questions'

Update checkbox in laravel controller

徘徊边缘 提交于 2019-12-06 06:29:42
I have check box like this: <input {{isset($shop['private_post'])&&$shop['private_post']=='Yes' ? 'checked' : ''}} id="private_post" value="Yes" type="checkbox" name="private_post"> in controller : $shop= shop::find($request['id']); $shop->update($request->all()); In edit mode When I checkbox true work correctly but when I unchecked checkbox dose not work. I create dynamically checkbox and I can not use this command If(!isset($request['private_post'])) $request['private_post']=0; $shop= shop::find($request['id']); $shop->update($request->all()); Try this: In Blade {!! Form::checkbox('private

What does double colon in laravel means

送分小仙女□ 提交于 2019-12-06 06:13:45
问题 Example : Auth::guard($guard)->guest() I dont get what double colon (::) notation means in laravel framework. from http://php.net/manual/en/language.oop5.paamayim-nekudotayim.php I learn that it stand for scope resolution operator to access static, constant and overridden properties or methods of a class. but from laravel I learn that Auth means the alias for class facade so I need an explanation of the example above especially guard(parameter)->guest() means. I'm still new to php and now

If the second page has one item, the pagination is not displayed in laravel 5.3

依然范特西╮ 提交于 2019-12-06 05:28:54
let's assume we have 11 items and we set 10 items per page so the second page will have 1 item, in this case the pagination in second page is not displayed but when add another item and the list becomes 12 and the second page has 2 items the pagination is displayed. Controller: $cities = City::orderBy('id', 'desc')->paginate(10); return view('cities.home', compact('cities')); View: <div class="panel-body"> <div class="table-responsive panel panel-sky"> <table class="table table-striped table-hover"> <tr> <th>#</th> <th>Name</th> <th>Created At</th> <th>Action</th> </tr> @foreach($cities as

TokenMismatchException in VerifyCsrfToken.php line 67 on laravel using ajax

扶醉桌前 提交于 2019-12-06 03:31:14
This view has a link which calls a javascript function @extends('layouts.main') @section('content') <table class="table"> <tr> <th>ID</th> <th>Nombre</th> <th>Opción</th> </tr> @foreach ($tasks as $task) <tr> <td>{{$task->id}}</td> <td>{{$task->name}}</td> <td><a href="javascript:void(0)" onclick="eliminar({{$task->id}})" class="btn btn-danger">Eliminar</a></td> </tr> @endforeach </table> @stop and here is the javascript code function eliminar(id){ $.ajax({ type: "DELETE", url: "task/"+id, success: function (data) { console.log(data); }, error: function (data) { alert('Error:', data); } }); }

Override table prefix for a model

陌路散爱 提交于 2019-12-06 03:10:56
问题 Hello I've in config/database.php a prefix (mysql) like this: 'prefix' => 'myprefix_', But I need, only for one model, to use a different prefix like: protected $table = 'otherprefix_mytable'; In this way laravel looking for "myprefix_otherprefix_mytable". Any help? 回答1: In your app/config/database.php make 2 different connections like 'connections' => array( # first prefix 'mysql1' => array( 'driver' => 'mysql', 'host' => 'host1', 'database' => 'database1', 'username' => 'user1', 'password'