laravel-4

Getting the name of the foreign key with eloquent

北慕城南 提交于 2019-12-06 09:43:44
This must be very basic stuff but I can't seem to find out how to do it. I have a one to many relationship between to tables: Unit and Army (an army contains many units) and these are my models: class Army extends Eloquent { protected $guarded = array(); public static $armies = array(); protected $table = 'armies'; public function units() { return $this->hasMany('Unit'); } } and: class Unit extends Eloquent { protected $guarded = array(); public static $units = array(); protected $table = 'units'; public function armies() { return $this->belongsTo('Army', 'army'); } } So, in my Unit table I

Eloquent Outside of Laravel with jenssegers/laravel-mongodb multiple DB connections

偶尔善良 提交于 2019-12-06 09:30:42
问题 I am trying to connect Eloquent to multiple databases sqlserver for the default and mongodb for the secondary connection. I am using jenssegers/laravel-mongodb pulled in using composer. Here is my database file use Illuminate\Database\Capsule\Manager as Capsule; $capsule = new Capsule; $capsule->addConnection([ 'driver' => 'sqlsrv', 'host' => '******', 'database' => '*****', 'username' => '*****', 'password' => '*****', 'prefix' => '', ], 'default'); $capsule->addConnection([ 'driver' =>

Decrease product quantity in database after order is placed with Laravel

穿精又带淫゛_ 提交于 2019-12-06 09:28:20
I have cart on the site and so far everything work perfectly. Now I'm trying to make quantity for each product which admin can add in backend ( already done ) and when customer order product(s) to decrease quantity in database. So far as I said admin panel is ready and can add quantity to product which is saved in database. Here is my cart submit controller public function orderSubmit() { $cart = Session::get(self::CART_SESSION_KEY, array()); if (count($cart) < 1) { return Redirect::to('/'); } $validatorRules = array( 'captcha' => 'required|captcha' ); Input::merge(array_map('trim', Input::all

laravel 4 persisting data ongoing - jquery ajax submit

僤鯓⒐⒋嵵緔 提交于 2019-12-06 09:28:03
问题 I'm having ongoing problems with laravel 4.1 sessions and getting unexpected behaviour. Depending on how I call the controllers method the session either works or doesn't My app makes a call to a POST route - to add items to a cart which is a session. For some reason the session does not get updated.However if I make a call to the same function with a GET request the function works as expected. My routes.php contains these two routes: Route::get('testAdd', array('uses' => 'ProductsController

Laravel dosen't connect with Oracle

懵懂的女人 提交于 2019-12-06 09:26:19
问题 I'm using yajra/laravel-oci8 for Oracle connection with laravel. But I couldn't connected to Oracle, from my client PC to Server. showing this error: I'm using this code in database.php: 'oracle' => array( 'driver' => 'oracle', 'host' => '192.168.152.189',// this is my server IP 'port' => '1521', 'database' => 'ocp', 'username' => 'ocpl', 'password' => '123456', 'charset' => 'AL32UTF8', 'prefix' => '', 'port' => 1521 ), But I'm connected with Sql Developer. see the Sql-Developer Property: 回答1

dump-autoload command from php

岁酱吖の 提交于 2019-12-06 09:19:51
I am building a web application where the user dynamically can upload Controllers php files from the web browser. There is a problem in all of this. Since every class should be compiled in order be used inside of laravel, the commmand composer dump-autoload must be executed. But I do not want to do this manually from the terminal. Inside of a "register class" I have called explicitly some commands that have not worked for me, for example: Artisan::call('dump-autoload'); exec("/path/to/app/composer dump-autoload"); shell_exec('php artisan dump-autoload'); shell_exec('composer dump-autoload');

Submitting an Array of Checkbox Values with AngularJS & Laravel 4. Checkboxes not Checking (Visually)

妖精的绣舞 提交于 2019-12-06 09:11:47
Update After experimenting more with the solution(s) from: How do I bind to list of checkbox values with AngularJS? I am a bit closer. This is what I've updated my <input type="checkbox"> to: <input type="checkbox" name="items[]" value="{{ $item['item_id'] }}" ng-checked="formData.items.indexOf({{$item['item_id']}}) > -1" ng-click="toggleSelection({{$item['item_id']}})" /> Now, I can see the data being updated/logged to the console and watching the HTML via dev-tools I can see the checked="checked" being added to the element. Although still not checked visually . I think for now, I will resort

Using Laravel 4's Input class outside the framework

房东的猫 提交于 2019-12-06 09:02:18
问题 I like the way Laravel 4 handles the input, and how you can get the value via Input::get() no matter if its sent by get, post or whatever. I'm working on a project that does not use Laravel as the framework, but it will be great if i can use the Input class. Can anyone help me how can this be done? 回答1: Input is, in fact, the Request class. You can require it using Composer: composer require "illuminate/http" "4.x" Require Composer autoload.php in your project: require 'vendor/autoload.php';

How do I mock the Auth class in Laravel 4?

无人久伴 提交于 2019-12-06 08:59:02
问题 I'm trying to make my AuthController testable. I start by injecting the Auth class so I can mock it in my test: public function __construct(Auth $auth) { $this->auth = $auth; } Then I use the injected class later when I check if the login succeeded: public function postLogin() { // instead of Auth::attempt(Input::all()) if ($this->auth->attempt(Input::all()) { return 'you are logged in!'; } else { return 'login failed!'; } } When I submit my login form I get an error that the Auth::attempt

Multiple tables in one model - Laravel

こ雲淡風輕ζ 提交于 2019-12-06 08:57:10
问题 My Index page uses 3 tables in the database: index_slider index_feature footer_boxes I use one controller (IndexController.php) and call the three models like so: public function index() { return View::make('index') ->with('index_slider', IndexSlider::all()) ->with('index_feature', IndexFeature::all()) ->with('footer_boxes', FooterBoxes::all()); } The three models above need ::all() data, so they are all setup like this: class IndexSlider extends Eloquent { public $table ='index_slider'; }