laravel-4

Passing data from view to controller in Laravel

ⅰ亾dé卋堺 提交于 2019-12-25 04:01:05
问题 I understand that passing record ids through the url isn't usually a good idea, but I am wondering how I can avoid it in my case: My objective is to list job statuses on a user dashboard and allow users to adjust the status. I create my view and pass variables to it using the session: userController.php public function getdashboard() { //reading the user information $arrPageData['user'] = Sentry::getUser(); //reading the job interviews $arrPageData['jobInterviews'] = JobInterview:

MethodNotAllowedHttpException on resource defined method Laravel-4

折月煮酒 提交于 2019-12-25 03:59:08
问题 I created a very simple form so that I could use a submit button rather than a link to open up an edit users page. Using a link works perfectly, but the form button fails and yields a MethodNotAllowedHttpException even though the method ("edit") is perfectly defined in the UsersController resource and otherwise works fine. Route: Route::resource('users','UsersController'); UsersController: public function edit($id) { $user = $this->user->find($id); return View::make('users.edit')->with('user'

Update route generates incorrect url

荒凉一梦 提交于 2019-12-25 03:58:15
问题 This is my html blade code {{ Form::open(array('route' => 'restaurants.update', 'class' => 'mainInformationContrainer')) }} <ul> <li> <label>Website</label> <div class="oneInfo"> <input type="text" value="{{$restaurant->website}}" /> </div> </li> <li> <input type="submit" value="Save Changes"/> <input type="button" value="Cancle" class="cancelButton"/> </li> </ul> {{ Form::close() }} But the url for the form is : public/restaurants/%7Brestaurants%7D Thought I already have the route: Route:

Failed to load magic database at '' Laravel 4

*爱你&永不变心* 提交于 2019-12-25 03:25:07
问题 $rules = array('title' => 'required', 'thumbnail' => 'image|size:500'); $inputs = array('title' => $this->title, 'thumbnail' => $this->thumbnail,); $validator = Validator::make($inputs, $rules); if ($validator->fails()) { } If I remove the 'thumbnail' it's working, but if it's there, it crashes when it does the $validator->fails() 回答1: The Failed to load magic database message is a PHP error message, not related to Laravel. There's a problem with your libmagic installation, or it is not

Get column of other table in Laravel ORM from self referencing table get N level hierarchy JSON

好久不见. 提交于 2019-12-25 03:22:38
问题 I have two tables abc and def . I have models of these two tables named respectively Abc and Def . In Abc , I declare these two functions: public function child() { return $this->hasMany('Abc', 'parent'); } // recursive, loads all descendants public function children() { return $this->child()->with('children')->orderBy('sort_order'); } // parent public function parent() { return $this->belongsTo('Abc','parent'); } // all ascendants public function parentRecursive() { return $this->parent()-

How to pass id value from select list to controller when controller expects an object? laravel-4

☆樱花仙子☆ 提交于 2019-12-25 02:47:18
问题 I've constructed a select list in a dashboard view, which lists id and name of various components. The data is passed to a controller that makes a view using the passed id to pull up the correct component data for that id. Problem is that the controller is constructed to expect an object from which to get the id, so that when I submit the id from the list, I get a "Trying to get property of non-object" error. (It doesn't matter whether I submit to the route or directly to the controller; I

URL helper functions within an Artisan command return empty base URL

帅比萌擦擦* 提交于 2019-12-25 02:37:20
问题 When I call any of the url helper functions, e.g URL::asset('foo/bar') from within a command the base URL is an empty string, and the url returned is http://:/foo/bar I am running the command by calling php artisan myproject:MyCommand from a command line. Where MyCommand is a class that extends Illuminate\Console\Command I have set my url in config/app.php but I only get a fully qualified url when I run from an HTTP Request I am using Laravel Framework version 4.1.24 回答1: Where did you get

Laravel ignore validation while updating record

杀马特。学长 韩版系。学妹 提交于 2019-12-25 02:25:27
问题 Validation for my model looks like: public static $rules = array( 'email' => 'required', 'password' => 'required' ); How can i tell laravel not to check the validation for "password" field if user is going to update the record and also i want to retain the previous password in the database until user fills the password again from the edit form? 来源: https://stackoverflow.com/questions/24387300/laravel-ignore-validation-while-updating-record

Blade template not executing @else clause

社会主义新天地 提交于 2019-12-25 01:32:37
问题 I have a Blade template that loads a list of users and displays their various details. If a user has no mobile number I want to display the message "No Mobile Number" (I've tried single and double quotes), this never gets displayed: @if ($person->Mobile >= "") {{ $person->Mobile }} @else 'No Mobile Number' @endif I tried substituting the "No Mobile" message with {{ $person->EMail }} (which I'm displaying elsewhere, so I know everyone has an email address), but still go nothing, as far as I

Laravel parent child relationship, Don't validate self as parent

与世无争的帅哥 提交于 2019-12-25 01:26:24
问题 In Laravel, i have projects table. A project can be sub-project of another project. I keep this parent-child relationship in the same projects table. When editing a project, the user chooses parent project from a select box. However i want to prevent the user from selecting the same project that is being edited; as a parent project. This would cause loops, thus errors. How can i achieve this? Best solution i can think of is to write a custom validation rule, however, in that case, how can i