laravel-4

Laravel application language change?

假如想象 提交于 2020-01-15 07:12:33
问题 I have recently developed and application in Laravel for a German client. Now the client wishes to know if the application can viewed in German instead of English. I have designed all the views of the front end using Blade in English of course. Now is there a way in which the views translate to the desired language? Is there a package or another way to accomplish this? 回答1: Laravel provides localisation functionality baked in http://laravel.com/docs/4.2/localization though you are going to

Laravel migrate creating table with more than one primary key

感情迁移 提交于 2020-01-15 07:06:07
问题 I issued the command: php artisan generate:scaffold order --fields="customer_id:integer(11), order_date:date, notes:text” When it gets to migrate, it ends with the error: General error: 1 table "orders" has more than one primary key (SQL: create table "orders" ("id" integer not null primary key autoincrement, "customer_id" integer not null primary key autoincrement, "order_date" date not null, "notes" text not null)) There is a Customer model and corresponding table that I am trying to

Laravel4 Model primary key value is lost after insert

ぐ巨炮叔叔 提交于 2020-01-14 22:32:13
问题 <?php // Model class ProfileDelivery extends \Eloquent { protected $table = 'profile_delivery'; protected $guarded = array(); public $timestamps = FALSE; } // Somewhere $deliveryGuy->id = 1; print $deliveryGuy->id; // Prints 1 if (!$deliveryGuy->save()) { throw new \Exception('Cant save .'); } print $deliveryGuy->id; // Prints 0 Can anyone explain me why the ID value is lost? 回答1: Not sure if you solved this for your situation but in Laravel 5.1 this just happened to me - the primary key of

Laravel4 Model primary key value is lost after insert

有些话、适合烂在心里 提交于 2020-01-14 22:31:57
问题 <?php // Model class ProfileDelivery extends \Eloquent { protected $table = 'profile_delivery'; protected $guarded = array(); public $timestamps = FALSE; } // Somewhere $deliveryGuy->id = 1; print $deliveryGuy->id; // Prints 1 if (!$deliveryGuy->save()) { throw new \Exception('Cant save .'); } print $deliveryGuy->id; // Prints 0 Can anyone explain me why the ID value is lost? 回答1: Not sure if you solved this for your situation but in Laravel 5.1 this just happened to me - the primary key of

Laravel4 Model primary key value is lost after insert

╄→尐↘猪︶ㄣ 提交于 2020-01-14 22:31:18
问题 <?php // Model class ProfileDelivery extends \Eloquent { protected $table = 'profile_delivery'; protected $guarded = array(); public $timestamps = FALSE; } // Somewhere $deliveryGuy->id = 1; print $deliveryGuy->id; // Prints 1 if (!$deliveryGuy->save()) { throw new \Exception('Cant save .'); } print $deliveryGuy->id; // Prints 0 Can anyone explain me why the ID value is lost? 回答1: Not sure if you solved this for your situation but in Laravel 5.1 this just happened to me - the primary key of

Laravel 4.2 Soft Delete not working

大城市里の小女人 提交于 2020-01-14 12:36:37
问题 I Use laravel 4.2.8 and Eloquent ORM. When I try to softdelete its not working. It delete data from my database. I want to delete data logically not physically. Here I give my code what I tried model use Illuminate\Auth\UserInterface; use Illuminate\Database\Eloquent\SoftDeletingTrait; class User extends Eloquent implements UserInterface { /** * The database table used by the model. * * @var string */ protected $table = 'users'; public $timestamps = true; protected $softDelete = true;

Inheritance in Laravel framework

回眸只為那壹抹淺笑 提交于 2020-01-14 06:47:05
问题 Is possibile to use inheritance in laravel model? I explain: is possible to exend a model, which extends eloquent class? class A extends Eloquent { } class B extends A { } A e B are also 2 different tables and B has A_id as foreignkey and other fields. How could be the constructor of class B? is it a ragionable solution or better use hasOne relationship? no every A object are also B object. Es. user and teacher Thank you 回答1: I’m having difficulty understanding your supplementary details, but

Laravel wherebetween with orwherebetween

感情迁移 提交于 2020-01-14 05:43:06
问题 I have written a Laravel query. I am using whereBetween and orWhereBetween along with a where statement on a column named 'shareable', which should return one row. But this query does not take where condition into consideration. It took only whereBetween and orWhereBetween . What can be the reason. my query $childs = Program::whereIn('id', $programs_by_date) ->where('shareable', '=','1') ->wherebetween('starting_date', [$new_start_date,$new_end_date]) ->orwherebetween('ending_date', [$new

Laravel 4 Route issues with multiple and optional get params

China☆狼群 提交于 2020-01-14 03:35:34
问题 I am creating a webservice with Laravel 4 and I am facing an issue with Optional params. Consider scenario below:: http://webservices.example.com/city/mumbai/q/hospital/ Which renders results for a search page with few filters e.g. category and location and ofcourse params for pagination too. Now these Filter params may be optional and may not have a pre-defined order coz it depends on how user might select filters. So lets say following URL forms are possible http://webservices.example.com

Laravel 4 migration: class not found exception

梦想与她 提交于 2020-01-13 12:12:54
问题 So apparently now I get this weird error when I want to migrate my database {"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class '' not found","file":"C:\\xampp\\htdocs\\l4crm\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Migrations\\Migrator.php","line":301}}[Finished in 1.3s] Everything used to work of course and it doesn't matter which files I try to migrate (I tried only migrating one table, then another, they all give the same error) Any