laravel-4

Problems linking view and controller

ⅰ亾dé卋堺 提交于 2019-12-13 03:01:17
问题 This is the error I am getting on the sample view: Undefined variable: sampleRecord This is the controller code: public function show($sample_id) { return View::make('samples.show')->with([ $this->sampleRepository->find($sample_id), $this->sampleRecord->getSamplePartNumberRecord, ]); } This is the view code: <p>{{ $sampleRecord }}</p> @foreach($sampleRecord->SamplePartNumbers() as $samplePartNumberRecord) <p>Sample Part Number: <br />{{ $samplePartNumberRecord }}</p> @endforeach 回答1: your

Laravel relation many to many with additional pivot

只愿长相守 提交于 2019-12-13 02:56:28
问题 Status Update I have implemented morph to many relationship type but how can I insert into the addition field? The code for the polymorphic relation is: public function mailmessages() { return $this->morphToMany('Mailmessage','rel','mailmessage_rels','rel_id','mailmessage_rel_id') ->withPivot(['addition']); } Original Post I have a Laravel project that uses many to many relations and in the pivot table I have additional field that describes the related model. For example I have this mail

Laravel Cookies

混江龙づ霸主 提交于 2019-12-13 02:50:57
问题 I've been searching and asking around, but i can't find what i am looking for, or anything similair. I am looking for a way to pass along certain settings for a user. I have a menu in my back-end which the user can narrow or keep wide. Standard the menu is wide. If a user devides to use the narrow menu, and goes to another page, the menu 'resets' to the default wide state. I'd like to pass along this 'setting' with the user. I know i have to make a cookie. but what else?? no idea. !IMPORTANT!

composer dump autoload and git

亡梦爱人 提交于 2019-12-13 02:42:44
问题 We have decided to commit the vendor directory inside our git repo for deployment practicality. Things are working however everytime we run composer dump-autoload it modifies the following files which is quite annoying as it doesn't seem to represent a specific state of files it looks like a random number every time you re-run it. How should I handle this? vendor/autoload.php return ComposerAutoloaderInit54ff9d13a4342a89ea5000269df2222::getLoader(); vendor/composer/autoload_real.php spl

Laravel Queue: How to use on shared hosting

旧时模样 提交于 2019-12-13 02:37:38
问题 I have read tutorials on Laravel Queue using Beanstalkd etc and the idea of using queue is fantastic because in my current project, sending a Welcome mail to a registered user takes up to 10 seconds to process cause of the attachment of a logo. I can imagine what will happen if more users register at an instance. So, using a queue for this will speed up things. In the shared server I am working on, I have no SSH Access . So, setting up the queue according to the tutorials is far fetched. I

Error when using ->paginate() with Laravel

北慕城南 提交于 2019-12-13 02:35:29
问题 So I have this Topic controller on my forum. The Topic has many Posts and the Post belongs to the Topic. class Topic { public function posts() { return $this->hasMany('Post'); } } class Post { public function topic() { return $this->belongsTo('Topic'); } } To get the informations about a Topic and all of the posts related to it, I do: $query = Topic::where('id', $id)->with('posts'); But every time I try to add : $query = $query->paginate(15) and I use $topic->title , I get : Undefined

Laravel echoing object property after checking for Existence

☆樱花仙子☆ 提交于 2019-12-13 02:33:57
问题 In Laravel there is a shortcut method for checking and printing variable if it exists: {{ $name or 'Default' }} Is there any similar syntax for object properties? Because that kind of syntax will throw an error in case I'll try to check an object property for existence: {{ $object->property or 'Default' }} I know I can solve that with plain PHP like that: {{ isset($object->property) ? $object->property: 'Default' }} But isn't that odd? Object properties are longer than variables and they also

Laravel optional routing parameter

我的梦境 提交于 2019-12-13 02:18:44
问题 I am trying to build up my routes file and for the application we are building we may have a route such as: /services/{game}/{id} Is there a way to have that {game} parameter, but not actually pass it to the controller? Its basically there, but doesn't have to be anything specific and the controller doesn't need to know its there, it's purely for the users eye to make their URL make sense. 回答1: That is perfectly possible, you can catch it in the controller without doing anything with it,

How do I access nested arrays within laravel views? Laravel 4

社会主义新天地 提交于 2019-12-13 02:09:09
问题 I am unable to access the internal values of the following array. for Object 1 to access the *VALUES IN THE FIRST OBJECT I USED * values I used the following method: {{$info[0]->title}} {{$info[0]->about}} I am trying to access the VALUES IN THE INTERNAL ARRAYS ... How can I? [ {*"pageID":1,"userID":2,"title":"CrossFit Invictus","logo":"","about":"Invictus is a 5,000 sq\/ft. fitness coaching facility equipped with men\u2019s and women\u2019s locker rooms and a designated kid\u2019s area,

Why the Auth::attempt method always returns false?

99封情书 提交于 2019-12-13 01:54:05
问题 I'm trying to do a basic authentication and when I try to authenticate the user,but Auth :: attempt method returns false Blade {{ Form::open(array('url' => 'usuario')) }} <input type="text" class="text" id="email" name="email" placeholder="Correo" {{(Input::old('email')) ? 'value ="'. Input::old('email').'"' : '' }}> <p>{{ $errors->first('email') }}</p> <input type="text" class="text" id="password" name="password" placeholder="Contraseña" > <p>{{ $errors->first('password') }}</p> {{ Form: