laravel-5.2

How to move Laravel in simple hosting?

萝らか妹 提交于 2019-12-11 05:26:14
问题 I try to move Laravel project in simple hosting(PHP), but this hosting does not has SSH and command terminal. Can I somehow to run this project in hosting? 回答1: You can run all needed commands on local server (composer, migrate etc.) then move entire directory to the shared server and configure domain to directory with your project, for example: /home/shared/laravel-project/public On local server you can use mysqldump (or pg_dump) to export database, so then you can import database via for

Retrieve values from 2 different tables and put them in a view with Laravel

橙三吉。 提交于 2019-12-11 04:54:10
问题 I have 2 table as Food : Food_id(pk) Foodname Description Image Price Ans other table is Restaurant : Res_id(pk) ResName Location I make Pivot table food_restaurant as: id Food_id(fk) Res_id(fk) I want to show Location of Restaurant along with food details in my view.For that I make function in model Food.php as public function restaurant() { return $this->belongsToMany('App\Restaurant','food_restaurant','Food_id','Res_id'); } And other model Restaurant.php as public function food() { return

Multiple tables with one to many relationship(Laravel)

こ雲淡風輕ζ 提交于 2019-12-11 04:48:17
问题 I have 3 tables namely A, B and C. All 3 of them need to make use of a notes table(i.e. A has many notes and a note belongs to A. The same follows for remaining 2 tables). So I created 3 more tables: A_note, B_note and C_note(as mentioned here: multiple tables need one to many relationship). Is there a way to do CRUD operations on these tables(A_note, B_note and C_note) similar to the way we handle pivot table in many-to-many relationship? Please suggest a way forward. 回答1: You should be

Column not found: 1054 Unknown column using join

坚强是说给别人听的谎言 提交于 2019-12-11 04:44:26
问题 I'm trying to retrieve the values based on the user's selected that I joined using first method. But when I tried to put the values in my form. It says SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sent_document_user.document.id' in 'on clause' (SQL: select documents . title , categories . category_type , documents . content , documents . id from sent_document_user inner join documents on documents . id = sent_document_user . document . id inner join categories on categories . id =

laravel DB::connection()->getPdo()::PARAM_STR not working

烈酒焚心 提交于 2019-12-11 04:34:11
问题 The function getPdo() with PARAM_STR in laravel DB::connection()->getPdo()::PARAM_STR is working fine with php 7.0.0 but not working with php 5.6.16 or lesser versions. How can I get the PARAM_STR from PDO instance in laravel with php 5.6.16 or less? I have tried DB::connection()->getPdo()->PARAM_STR but not working for me.. 回答1: The solution which worked for me is this.. static function db () { try { $db = DB::connection()->getPdo(); } catch (PDOException $e) { self::fatal( "An error

getRealPath() returns false (Laravel 5.2 & Image Intervention)

*爱你&永不变心* 提交于 2019-12-11 04:18:42
问题 When uploading images, getRealPath() always returns false : $image_file = $request->file('image_file'); $image_file->getRealPath(); // ---> FALSE Here is the result of dd($image_file); : Also, when I try to use it with Image Intervention: $image_file = $request->file('image_file'); Image::make($image_file->getRealPath())->..... I am getting the following error: NotReadableException in AbstractDecoder.php line 323: Image source not readable Obviously because getRealPath() returns false ...

Laravel read and write connection not in sync

微笑、不失礼 提交于 2019-12-11 03:09:55
问题 I'm using read and write MySQL connection setup in my Laravel 5.2 app: 'mysql' => [ 'write' => ['host' => env('DB_HOST_WRITE', 'localhost'),], 'read' => ['host' => env('DB_HOST_READ', 'localhost'),], 'driver' => 'mysql', 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'engine' => null ] The

Field UNIQUE (already taken) in edit?

倾然丶 夕夏残阳落幕 提交于 2019-12-11 03:08:59
问题 I have problem with validate when i edit my user. So when i edit i get message that name is already taken. How can i fix this? Because that name belongs to that user. So i need to change name again so that i can edit my user. if($user->business_user){ $this->validate($request,[ 'company_name' => 'required|unique:business_users' ]); } My view: <div class="col-md-6 col-sm-6 col-xs-12"> <div class="form-group" v-bind:class="{ 'has-error': basic_errors.company_name }"> <label class="form_title"

How to define a policy method with no argument in Laravel 5.2?

时光总嘲笑我的痴心妄想 提交于 2019-12-11 01:57:41
问题 It's sometimes necessary to check user authorization for an action with no argument like create/store method: class PostPolicy { use HandlesAuthorization; /** * Determine if the user can create a new post. * * @param \App\User $user * @return bool */ public function create(User $user) { if($user->is_admin) { return true; } return false; } } and use the authorize method in PostController: class PostController extends Controller { /** * Show the form for creating a new post. * * @return

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'property_id' cannot be null in Laravel 5.2

北战南征 提交于 2019-12-11 00:55:11
问题 I am trying to solve this problem, where I try to edit multiple files with the update method in laravel 5.2. When I run my process and save it returns the following error: QueryException in Connection.php line 729: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'property_id' cannot be null (SQL: insert into `files` (`name`, `property_id`, `updated_at`, `created_at`) values (58bf2825d39d9.jpg, , 2017-03-07 17:37:41, 2017-03-07 17:37:41)) This is my Promperties Migration Table and