laravel-4

Laravel 4 Redirect::action() “Route not defined”

ⅰ亾dé卋堺 提交于 2019-12-10 15:54:55
问题 I'm currently having troubles with Laravel 4. I would like to use slugs for forum categories and forum topics (slugs are unique). In order to determinate if the user is in a category or in a topic, I have this route: Route::get('forum/{slug}', function($slug) { $category = ForumCategory::where('slug', '=', $slug)->first(); if (!is_null($category)) return Redirect::action('ForumCategoryController@findBySlug', array('slug' => $slug)); else { $topic = ForumTopic::where('slug', '=', $slug)->first

Using accessor mutator with a belongsTo relationship

杀马特。学长 韩版系。学妹 提交于 2019-12-10 15:49:47
问题 Using Laravel 4 and I have a mutator set up in my User model: public function getFullnameAttribute($value) { return $this->first_name. ' ' .$this->last_name; } But I have a relationship set up in my Cars model for a user ID linked to that car: public function salesManager() { return $this->belongsTo('User', 'sales_manager')->select('first_name', 'last_name'); } I am calling that relationship on my Car table: $cars = Car::with('marqueBasic', 'modelBasic', 'salesManager') ->get(); Now, how can

Laravel Homestead: Nginx failing to start on Vagrant. Need root password to access Nginx logs

天大地大妈咪最大 提交于 2019-12-10 15:49:22
问题 Using Laravel Homestead to work with Laravel 4. After running vagrant up this morning, I was unable to access homestead.app:8000. I pinged it with no problem so I investigated my virtualbox and discovered that Nginx wasn't starting. I then attempted to view logs and I am denied permission from the /var/log/nginx directory which is owned by www-data adm . My question then, what is the su or sudo password which would allow me to access that directory? The documentation is surprisingly void of

Laravel 4: save a polymorphic relationship's record: undefined method newQuery()

柔情痞子 提交于 2019-12-10 15:34:42
问题 I have a polymorphic relationship in Laravel 4 and it's working like I want. I have another one, which doesn't work when I try to insert the related model, even though it is identical to the first one and I use it in the same way. I have Event model and an Article model: // Article Model class Article extends Eloquent { public function events() { return $this->morphMany('Event', 'eventable'); } ... // Event Model class Event extends Eloquent { public function eventable() { return $this-

Json giving 301 Moved Permanently

六月ゝ 毕业季﹏ 提交于 2019-12-10 15:16:21
问题 on Firefox, only on firefox it will popup and give you a warning "This web page is being redirected to a new location. Would you like to resend the for form you have typed to the new location." I got no form , i use javascript to extract values from textbox I checked on firebug it says PUT /admin/submit-scan/ 301 moved permanently PUT submit-scan 302 Found My JS function submitGoods(){ var registeredNo = $('input[name=registeredno]').val(); var weight = $('input[name=weight]').val(); $.ajax({

How to set disabled select option in Laravel?

霸气de小男生 提交于 2019-12-10 14:55:20
问题 In a controller function, I extract all the attributes and the attributes that I have already used. All the attributes: $attributeNames = array('' => 'Select Attribute Name') + AttributeName::lists('name' , 'id'); Already Taken Attributes: $selectedAttributeNames = $xmlDocument->masterInformation->masterAttributes; How can I make the selectedAttributeNames as disable please? Here is the output of var_dump($selectedAttributeNames) : object(Illuminate\ Database\ Eloquent\ Collection) #312 (1) {

How do you change the page name for Paginator?

自作多情 提交于 2019-12-10 14:54:59
问题 Current Paginator is using ?page=N , but I want to use something else. How can I change so it's ?sida=N instead? I've looked at Illuminate\Pagination\Environment and there is a method ( setPageName() ) there to change it (I assume), but how do you use it? In the Paginator class there is a method the change the base url ( setBaseUrl() ) in the Environment class, but there is no method for setting a page name. Do I really need to extend the Paginator class just to be able to change the page

Laravel Blade @foreach not working

旧城冷巷雨未停 提交于 2019-12-10 14:53:24
问题 I'm learning Laravel 4, so far so good. But for some weird reason blade's @foreach doesn't seem to work for a simple query. My code is: Route: Route::get('/users', function(){ $users = User::all(); return View::make('users/index')->with('users',$users); }); Now in index.blade.php my code is: @foreach ($users as $user) <p>User: {{ $user->username }}</p> @endforeach The weird thing is that when I dump the object in the view, it does work: {{ dd($users->toArray())}} The DB data is displayed raw

Call to undefined method Illuminate\\Database\\Schema\\Blueprint::increments()

限于喜欢 提交于 2019-12-10 14:50:03
问题 I'm new at laravel 4 and in my first project when I try to migrate this I got this error : Migration table created successfully. {"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Call to undefiend method Illuminate\Database\Schema\Blueprint::increments()","file":"foo","line:19"}} And this my migration code in app\migration\2014_10_14_114343_add_cats_and_breeds_table.php : use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration;

How to write a inner join in Eloquent ORM in laravel?

安稳与你 提交于 2019-12-10 14:25:01
问题 I have a tables named buildings and flats buildings table Building_Id | Building_Name | .......| Building_Owned_By | .... flats table Flat_Id | Flat_Name | ........| Fk_Building_Id | ..... and in My Models Building class Building extends Eloquent { protected $primaryKey = "Building_Id"; protected $table = 'buildings'; ....... ....... public function flat() { return $this->hasMany('Flat', 'Fk_Building_Id', 'Building_Id'); } } Flat class Flat extends Eloquent { protected $primaryKey = "Flat_Id"