laravel-4

Laravel/Angular: passing data within php page to angularjs

别等时光非礼了梦想. 提交于 2019-12-04 14:44:04
I have the following laravel html/blade page and i want to pass in a storeid that then can get picked up via angular to then use to get and do some workings with. Below is how i am accomplishing it NOW but is there a better way to produce the same? Blade Partial <div ng-controller="storeChartCtrl" data-storeid="{{ $store['id'] }}"> <p>{{ $store['name'] }} Sales</p> ... </div> Angular Ctrl .controller('storeChartCtrl', ['$scope', 'Store', function($scope, Store){ //-- get the requested store sales var storeid = JQ('#storeChart').data('storeid'); $log.info(storeid); .... This currently works and

Using Laravel 4's Input class outside the framework

会有一股神秘感。 提交于 2019-12-04 14:19:05
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? 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'; And use it: $input = Illuminate\Http\Request::createFromGlobals(); var_dump($input->all()); 来源: https:/

Laravel 4: validate checkbox at least one

吃可爱长大的小学妹 提交于 2019-12-04 14:18:28
I need to validate checkbox array: <input name="cats[]" type="checkbox" value="1"> sport <input name="cats[]" type="checkbox" value="2"> music <input name="cats[]" type="checkbox" value="3"> business I found "array" validation in documentation: Validator::make( [ 'cats' => Input::get('cats') ], [ 'cats' => 'array' ] ); Is there any built-in way to check if at least one item checked? Also, how to check if values submitted match a given list? You can use min: value to validate a numeric value and you can also use it to validate an array's size. Validator::make( [ 'cats' => Input::get('cats') ],

Laravel 4 restful delete a record with a resource controller

人走茶凉 提交于 2019-12-04 14:03:18
I am new to Laravel framework but I really like it. My biggest problem is I have been searching on how I can delete a single record using resource controller. Controller method: public function destroy($id) { $department = Department::find($id); $department->delete(); } Delete link I have tried: <a class="btn btn-xs btn-danger" data-method="delete" href="{{ URL::to('department/' . $department->id) }}"><i class="icon-remove"></i></a> Javascript: <script type="text/javascript"> $(function(){ $('[data-method]').append(function(){ return "\n" + "form action='" + $(this).attr('href') + "' method=

Laravel: Controller does not exist

房东的猫 提交于 2019-12-04 13:39:32
问题 I added new controller in /app/controllers/admin/ folder and added the route in /app/routes.php file as well. Then i run the following command to autoload them php artisan dump-autoload I got the following error Mcrypt PHP extension required. I followed instruction given at https://askubuntu.com/questions/460837/mcrypt-extension-is-missing-in-14-04-server-for-mysql and able to resolve the mcrypt issue. After that i run the php artisan dump-autoload command but still getting following error {

Laravel 4.2 Composer install error: “could not scan for classes”

元气小坏坏 提交于 2019-12-04 13:38:40
I want to install on my new Laravel 4.2 installation some packages via Composer. However, I am getting an exception. This is my Composer file: { "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "license": "MIT", "require": { "laravel/framework": "4.2.*", "zizaco/confide": "~4.0@dev", "zizaco/entrust": "1.2.*@dev", "barryvdh/laravel-ide-helper": "1.*", "fzaninotto/faker": "1.3.*@dev", "bllim/datatables": "~1.3", "barryvdh/laravel-debugbar": "~1.7" }, "require-dev": { "way/generators": "~2.6", "barryvdh/laravel-ide-helper

How to structure a platform with sub apps in Laravel 4?

核能气质少年 提交于 2019-12-04 13:26:31
问题 I need to develop several websites with common features and flows, the only thing that will dramatically change is the CSS, even the HTML will be common. I'm having troubles to assemble this structure in Laravel 4, since I'm still a begginer at the framework. I need to have a "super project" that all "sub projects" will inherit from. I need to be able to implement custom features and flows in a specific "sub project". I need to separate every project in it's own GIT repository. I would love

Delete rows with Laravel query builder and LEFT JOIN

孤街醉人 提交于 2019-12-04 13:10:08
How to delete rows from multiple tables in one query (with left join). The query: DELETE `deadline`, `job` FROM `deadline` LEFT JOIN `job` .... So, I try it like this: DB::table('deadline', 'job') ->leftJoin('job', 'deadline.id', '=', 'job.deadline_id') ->where('deadline.id', $id) ->delete(); Seems that Laravel doesn't support delete from multiple tables with left join. Is there a supported way or workaround? It seems that my way is not possible. So, I did it like this. $q = 'DELETE deadline, job FROM deadline LEFT JOIN job ...where deadline.id = ?'; $status = \DB::delete($q, array($id));

How do I mock the Auth class in Laravel 4?

≡放荡痞女 提交于 2019-12-04 12:42:05
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 method is not defined: FatalErrorException: Error: Call to undefined method Illuminate\Support\Facades

Eloquent morphOne relationship doesn't limit to one relation

╄→гoц情女王★ 提交于 2019-12-04 12:35:39
问题 I am having a issue with an Eloquent morphOne relationship where it is creating new entries rather than updating the one that already exists. Basically I have a number of models (for example, let's say Person and Building ) that both need a location, so I have created a Location model: class Location extends Eloquent { public function locationable() { return $this->morphTo(); } } Then in my other models I have this: class Person extends Eloquent { // ... /** * Get the person's location * *