laravel-4

Set value for amountToRelad var so it can be accessed on any method on the class

廉价感情. 提交于 2019-12-11 20:43:06
问题 I'm working in a OctoberCMS component and have some problems getting things working. Take a look at this code: class Payment extends ComponentBase { /** * This hold the amount with PayPal fee and discount applied and pass back to template * @var float */ public $amountToReload; public function onAmountChange() { $amount = post('amount'); if (empty($amount)) { throw new \Exception(sprintf('Por favor introduzca un valor.')); } $this->amountToReload = round($amount - ($amount * (float) Settings:

Laravel 4 Pivot Table (many to many) not loading

假如想象 提交于 2019-12-11 20:35:35
问题 I have 2 tables: 'users' and 'nests' and 1 pivot table: 'nest_user'. In my pivot table I have email addresses I want to filter against so I can grab all the nests which have the associated email addreses. Here is my scehma: public function up() { Schema::create('users', function(Blueprint $table) { $table->increments('id'); $table->string('username'); $table->text('bio'); $table->string('picture'); $table->string('email'); $table->string('password'); $table->integer('visits'); $table->integer

AngularJS - Dropdown Select Values are not in Order with ng-repeat

半世苍凉 提交于 2019-12-11 20:31:10
问题 I have a select drop down with the following data; (This is also the output to the console in Chrome). { 8: "Something", 9: "Something Again!", 10: "And again", 11: "And again!", 12: "etc...", 13: "etc etc...", } The html and angular for the select drop down; <select name="name" ng-model="choosen"> <option value="">Please Select</select> <option ng-repeat="(key, value) in data" value="[[key]]">[[value]]</option> </select> The data is got from using the following query within Laravel (4.2)

Specify columns for PDO::FETCH_KEY_PAIR

左心房为你撑大大i 提交于 2019-12-11 20:28:59
问题 I have a table with a following columns (more than 2) in my database: 1. id 2. name 3. email I am trying to fetch key value pairs using PDO by fetching the fetchMode to PDO::FETCH_KEY_PAIR and specifying columns id and name which works just fine But when i try to specify name and email as the desired columns i get the result set but the key is not name but usual numeric zero based indexes 0 => some@email.com Why? BTW i am using laravel, here is my code: $users = new User; $users-

How to write form markup in Laravel4

萝らか妹 提交于 2019-12-11 20:25:12
问题 Can you help me to write this form tag in blade sintax: <form name="room" id="1" method="post" class="narrow_width"> Thank you! 回答1: See http://laravel.com/docs/html for the Form syntax and methods. You can wrap these in Blade tags. {{ Form::open() }} {{ Form::text('username') }} Etc... In your case {{ Form::open(array('name' => 'room', 'method' => 'post', 'class' => 'narrow_width', id => '1')) }} 来源: https://stackoverflow.com/questions/20120553/how-to-write-form-markup-in-laravel4

laravel pdf package that can load views and support arabic

谁说胖子不能爱 提交于 2019-12-11 20:14:10
问题 I'm looking for a laravel 4 package that can do both, loading views and supporting arabic (and non-latin) fonts. I've tried domPDF and TCPDF but the first doesn't support Arabic while the second can't load views 回答1: Try "WKHTMLTOPDF" i use it with ZF2 and have no problems at all. Just google for sure there are packages. 回答2: Have you tried the package from Barry? (https://github.com/barryvdh/laravel-dompdf) This package has build-in support for views, accessing the storage folder for fonts

Foreign Key Constraint in Laravel Migration

回眸只為那壹抹淺笑 提交于 2019-12-11 20:11:41
问题 In Laravel 4, how can I add a foreign key constraint in a migration? In the migration for mytable (which references foreigntable ): // add Column $table ->string( 'foreigntable_id', 6 ); // add FK $table ->foreign( 'foreigntable_id' ) ->references( 'id' ) ->on( 'foreigntable' ); Error: [Exception] SQLSTATE[HY000]: General error: 1005 Can't create table 'mydb.#sql-1a24_2 1a' (errno: 150) (SQL: alter table `mytable` add constraint mytable_foreigntable_id_foreign foreign key (`foreigntable_id`)

Unsupported driver in laravel 4 when using laravel-oci8 package

主宰稳场 提交于 2019-12-11 19:57:49
问题 I am currently trying to use the laravel-oci8 package to connect to an oracle DB, I am receiving the error Unsupported driver [pdo-via-oci8] from laravel. it seems that the package may not have updated the list of available drivers? Is there a step I am missing to get this driver to be accessible? I have followed the read.me on github exactly.Also this is not a php error about a missing driver it is laravel specific. I have OCI8 enabled in php. 回答1: I am assuming that this is already fixed.

MySQL relation with multiple tables

别说谁变了你拦得住时间么 提交于 2019-12-11 19:50:56
问题 I have 4 mysql tables, as the following: Makes: id - make_name Models: id - model_name - make_id Trims: id - trim_name - model_id Forsale_Cars: id - trim_id - year - price in the Makes table I have ~700 records, so my question is, how can get a list of Makes which only have a child trim in the forsale table? I have 20 records in the forsale table, I want to get the list of Makes for these cars. I am using Laravel, so if anybody has achieved that previously using eloquent it will be great 回答1:

how to defined Custom foreign key in Laravel's “belognsToMany” method?

痞子三分冷 提交于 2019-12-11 19:43:44
问题 table MemberOwner: id | name | time table Member: id | sex | age talbe MemberOwner_Member: id | ownerid | memberid and this is my relationship-defined code: class MemberOwner extends Eloquent { public function members() { return $this->belongsToMany('Member','MemberOwner_Member','?','?'); } } look at the question mark above,how to fill with it?thank you,I've tried ownerid,memberid and memberid,ownerid but neither of them works,I need you help ,thanks again! 回答1: Try this: class MemberOwner