FAQ Database Discussion Community


How to perform a statement inside a query to check existence of a file that has the query id as name with less resources in laravel

php,function,laravel,laravel-4,eloquent
i'm looking for away to see if the query 'id' has a folder with the same id as name in the file system, i did it but it will slow down the drive in the future with lots of files $query = Model::all(); if(Input::get('field') == 'true'){ $filenames = scandir('img/folders'); $query->whereIn('id',...

laravel 5 and Ajax get data from database:

ajax,laravel,views
I have simple form: {{ Form::open(array('id' => 'frm')) }} <div class="form-group"> {!! Form::label('id','id:'); !!} {!! Form::text('id',null,['class' => 'form-control']); !!} </div> <div class="form-group"> {!! Form::submit('Update',['class' => 'btn btn-primary form-control']); !!} {!! Form::close() !!} I want to post the values from the form input fields to the controller then in the controller...

Restrict laravel to open url that is not in route

php,laravel,routing,laravel-5,laravel-5.1
I am Learning laravel now. Today I came across a problem that surprised me. I open this link in my browser: http://localhost/laravel/project/ch/resources/views/pages/blog.blade.php And I expect error 404. but it opens contains of this file. So, How to restrict laravel to do this. I want laravel to open only url mentioned...

Sync element to a child on Laravel

php,mysql,laravel,eloquent,laravel-5
My Shema database is User Table id login parent Sign Table id name user_id (Sign owner) Pivot table user_sign id user_id sign_id My User model contain public function signs() { return $this->belongsToMany('App\Sign', 'user_sign'); } public function parent(){ return $this->belongsTo('User', 'parent'); } public function children(){ return $this->hasMany('User', 'parent', 'user_id'); } And...

How to delete only the table relationed

sql,laravel,migration
I know how to create the migrations with laravel 5.1 and I have the following code public function up() { Schema::create('articulos', function (Blueprint $table) { $table->increments('id'); $table->string('title'); $table->string('content'); $table->integer('categoria_id')->unsigned(); $table->integer('creador_id')->unsigned(); $table->string('slug', 32); $table->timestamps(); }); Schema::table('articulos', function($table) { $table->foreign('categoria_id')->references('id')->on('categorias');...

Set options for ZADD command in laravel redis

php,laravel,redis,set
I'm trying to set options for ZADD with laravel redis but am failing. The option I need to set is NX, as stated in the documentation: ZADD options (Redis 3.0.2 or greater) ZADD supports a list of options, specified after the name of the key and before the first score...

Laravel 5: Call method in class before the method indicated by the route

php,laravel,laravel-5,laravel-middleware
I'm sure there's a well documented way to do this in Laravel, I'm just missing it or not understanding what I'm reading. I have an application that uses a token for accessing part of the website, rather than a username or password. That token identifies the job, checks the status...

Laravel trans helper function not picking the right file

php,laravel,translation,language-translation,registrar
I'm building a website in Laravel, I'm having it get the browser language and set the website's language accordingly. Problem is, nothing in Registrar.php seems to get translated in English or Dutch Could anyone please help me out? Thanks, g3...

Android post request in php

php,android,laravel,post
I'm trying to make a php script send an email whenever I make a post request. If I load my website in a web browser, it indeed sends a mail. But whenever I send a post request in Android (calling the postData method), nothing happens. Why doesn't it work? public...

Laravel: Retrieve polymorphic attributes efficiently

rest,laravel,polymorphism,eloquent
My actual Question is: How to return attributes to the client which I actually need, throw the rest away and be as efficient as possible? So, I have a construction where I basically have media objects, which can be of different types, like video, picture, link and so on. This...

Laravel 5 making a route for a specific link

laravel,laravel-5,laravel-routing
I have a link that goes to a address like http://localhost/pages/vehicles?show=61 Is it possible to make a route for that kind of link i tired below route but it does not work Route::get('/pages/vehicles?show={id}', ['middleware' => ['roles'], 'uses' => [email protected]', 'roles' => ['Admin']]); ...

Join this eloquent laravel5

php,laravel
I recieve correctly this two messages , but I need to JOIN this two results with Laravel5. Could anyone helps to me ? Or it's any possibilities to doing this with other form? $mensajes = Messageuser::find(1)->conversaciones()->get(); $mensajes2 = Messageuser::find(4)->conversaciones()->get(); echo $mensajes; echo $mensajes2; UPDATE The MessageUser use Illuminate\Database\Eloquent\Model; class MessageUser...

Error homestead up

laravel,vagrant,homestead
I'm installing homestead for Laravel 5 (Windows) I've Already installed Vagrant and VirtualBox Following this tutorial: https://laracasts.com/lessons/say-hello-to-laravel-homestead-two When i run homestead up This is the error result: C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/psych.rb:205:in `parse': (<unknown> ): did not find expected key while parsing a block mapping at line 3 column 1 (P sych::SyntaxError) from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/psych.rb:205:in...

Laravel 5.0: Form::select() called twice Eloquent Accessor by select name

php,laravel,eloquent,laravel-5,accessor
Blade template: {!! Form::model($category) !!} {!! Form::select('drinks_id', [...full list...]) !!} {!! Form::close() !!} 'drinks_id' called by Eloquent Accessor: public function getDrinksIdAttribute() { var_dump('get'); return 123; } When Form::select('drinks_id') execute, getDrinksIdAttribute() called twice and print string(3) "get" string(3) "get" from var_dump(). If I write this: {!! Form::model($category) !!} {!! var_dump($category->drinks_id) !!}...

Using Twigbridge in a Laravel 5.1 Package

laravel,twig
I'm trying to create a Laravel 5.1 package which uses Twigbridge instead of .php views. I can get normal .php views to display fine, but when I try to make use of .twig templates I'm only met with an error. Is it possible to use Twigbridge templates when creating views...

Laravel 5.1 throws ReflectionException after upgrade from 5.0

laravel,laravel-5
I have recently upgraded Laravel to version 5.1 from 5.0, but whenever I send an API response to the server, it throws an exception like the following: ReflectionException in RouteDependencyResolverTrait.php line 57: Class App\Http\Requests\User\GetRequest does not exist Before upgrading everything was working fine. This is the autoload section of my...

What is the best practice to implement update profile picture in PHP Laravel 5?

javascript,php,jquery,laravel,laravel-5
I'm trying to allow my user to update their profile photo and I'm wondering what is the best practice to implement something like that in Laravel. Here is my user profile picture. When they hover on it, they will have an option to update their photo. When the user click...

Laravel5: Access public variable in another class

php,class,oop,laravel,laravel-5
I have a middleware file called LanguageMiddleware.php: ... class LanguageMiddleware { //ISO language codes: public $languages = ['en','es','fr','de','pt','pl','zh','ja']; ... LanguageMiddleware.php is in laravelProj/app/Http/Middleware/ Here's my problem: I have a blade template file called master.blade.php where I'm attempting to output a list of languages @foreach (App\Http\Middleware\LanguageMiddleware\languages as $lang) <a class=\"setLang\" href=\"lang/en\">{{...

Laravel Collection installation with Composer and Laravel 5

laravel,composer-php,laravel-collection
I need help with a problem. I'm learning Laravel 5. And I've found a problem trying to do something. I tried to install Laravel Collection. I go to composer.json and I add this line on require: "laravelcollective/html": "5.1.*" But when I execute composer update on shell, I have an error:...

Laravel validator vs requests

laravel,laravel-5,laravel-validation
Hello, I want to understand how to handle data validation with Laravel 5. I see that this can be done using or the validator, or the request files. The thing is that there are many points I didn't get. What is the difference between using a request file for validation...

How to change default Nginx setting on Homestead Laravel Virtualbox VM

laravel,nginx,vagrant,virtualbox,homestead
I merely followed the default Laravel Homestead setup here using VirtualBox. Working great. But I need an additional Nginx rewrite setting in my apps vhost file on the VM, something like; location / { if ($request_method !~ "(POST)"){ rewrite .... } try_files $uri $uri/ /index.php?$query_string; } I can add that...

Laravel 5 pagination with trailing slash redirect to 301

php,laravel,redirect,pagination,laravel-5
I'm using Laravel 5 and notice that the pagination is adding a trailing slash before the ?page=# and with that, it always redirect to a 301 page. http://example.com/news/articles/?page=2 will do a 301 redirect to http://example.com/news/articles?page=2 This is causing my pagination using ajax to slow down because it is having 2...

Payum Laravel Package - Route not found

laravel,nvp
I'm using Payum/PayumLaravelPackage Package and I'm having a problem with this package. I have this method: public function prepareExpressCheckout() { $storage = $this->getPayum()->getStorage('Payment'); $details = $storage->create(); $details['PAYMENTREQUEST_0_CURRENCYCODE'] = 'EUR'; $details['PAYMENTREQUEST_0_AMT'] = 1.23; $storage->update($details); $captureToken = App::make('payum.security.token_factory')->createCaptureToken('paypal_ec', $details, 'done'); return \Redirect::to($captureToken->getTargetUrl()); } And...

Laravel 5 not storing checkbox value

php,laravel,checkbox,laravel-5
We are having a strange issue with Laravel 5 in that it is refusing to store the checkbox value. We are adapting the existing registration form that comes bundled with Laravel 5 and we are adding an optin checkbox but it seems the model does not recognise this as a...

Getting an image to render with php

php,image,laravel,image-processing
To keep it simple, I'm trying to display an image using php to help try and prevent any kind of a security loophole. I have the image being read through a php script and I am wanting to render it, so instead of going to http://example.com/path/to/uploads/dir/image.jpg I want to have...

Messed up a merge when trying to upgrade my Laravel application

git,laravel,github,merge
I have an existing laravel project which used an older version of Laravel 5.1. I wanted to upgrade my project to use Laravel 5.1.2. I followed this tutorial. So I added the laravel/laravel github repository into my git project as a remote called laravel, fetched it, then I created a...

PhpStorm - wrong syntax highlighting with Blade

laravel,syntax-highlighting,phpstorm,blade
When I create a Blade template in PhpStorm, for example login.blade.php, syntax highlighting works correctly. But when I name it layout.blade.php, it doesn't. Why? How can I fix it? ...

Laravel Interfaces

php,laravel,interface,namespaces
I used the following tutorial to get an idea about interfaces: http://vegibit.com/what-is-a-laravel-interface/ But I wanted to change the directory of where I am putting my interfaces to "App/Models/Interfaces". And so I did. But now I cannot get it to work anymore. Here is my code: Routes.php App::bind('CarInterface', 'Subaru'); Route::get('subaru', function()...

Get base_url using Jquery in Laravel

jquery,laravel,laravel-5
I am using laravel 5.0. I want to get base url of laravel page using jquery. I have tried the following function. function getBaseURL () { return location.protocol + "//" + location.hostname + (location.port && ":" + location.port) + "/"; } But this gives only http://localhost. I need my full...

Update resource AJAX Laravel 5

php,jquery,ajax,laravel
I'm getting stuck with Ajax, i dont know why my ajax call returns error everytime. My update method dont even detect an ajax request. I've never done ajax before, but i understand the logic behind it so excuse my ignorance if i ask for dumb things lol.. Route::post('edit/organisation/{id}',['uses' => [email protected]',...

Nested comments with Laravel

php,mysql,laravel,laravel-4
I'm currently trying to replicate something similar to a forum, but I'm stumped on how I could create nested comments. I understand that for regular replies I could create a replies table and run a loop for each comment that matches the thread id. But I don't know how I...

Laravel: How does the query builder handle ->first()?

php,laravel,query-builder
How does the query builder handle ->first()? Does it simply do a Limit 1 or does it do some advanced checking to make sure if only 1 row is returned? In rare cases, the application may want to ensure that ONLY 1 row will be returned. Perhaps ->first() is not...

Deleting migrations results in an Exception

php,laravel,laravel-5,composer-php,autoload
In my Application, when I run php artisan migrate:make create_location_user_table, then delete the generated file (doesn't matter if I delete the line created in vendor/composer/autoload_classmap.php, the php artisan migrate:refresh command throws an error: include(<path_to_project>/database/migrations/2015_06_21_105357_create_location_user_table.php): failed to open stream: No such file or directory After running commands to get rid of...

Handling 500 Internal Server Error from DomDocument in Laravel 5

php,laravel,exception-handling,laravel-5
The library I wrote for Laravel uses DomDocument. I use this library under my Controller, and its namespace is app/Services/Verify/. The library gets initialized and used when I put it some inputs into a form. When the library fails, Laravel would fail the way it would - returning the following...

Redirect to Login page if ther user not logged in Laravel

laravel,laravel-5,laravel-routing
I am using Laravel version 5. I have a route file for my project which contains plenty of lines. I need to put authentication like Redirect to login page if the user is not logged in. And I also want to prevent direct URL access if the user not logged...

laravel file uploading using json

jquery,ajax,json,laravel,laravel-5
I am using laravel 5. I have did the following code to post data using json to my controller. But I cannot make file uploading by this manner. e.preventDefault(); $.ajax({ type: 'POST', cache: false, dataType: 'JSON', url: 'tasks', data: $('#my_form').serialize(), success: function(data) { console.log(data); }, }); I have the following...

count() “where” statement in Laravel blade?

laravel,laravel-4,blade
I am interested in displaying quick counts of email stats in my application, but I'm getting hung up on finding an efficient way to generate the counts. I am hoping to just use the eloquent relationship with some sort of "count where" statement inside of blade. Getting the total count...

Laravel get posts with multiple tags

php,sql-server,laravel,eloquent
I'm working with a laravel belongsToMany relationship between Post and Tag. What I'm trying to do is get all Posts where it has multiple tags. I've tried all sorts of eloquent queries, but I can't get it at all. Currently I can get an array of post_id's and tag_id's, as...

Get a simple boolean value from a GET request using jQuery

jquery,ajax,laravel
guys, Well I have a simple form with a dropdown to select one 'product types' of a few. When an item is selected, it'll trigger an onChange event. A given product type can have an expiration date or not. I want to change the visibility of a field according to...

Am I safe?? [trying to prevent sql injection] [duplicate]

php,mysql,security,laravel,pdo
This question already has an answer here: How can I prevent SQL-injection in PHP? 28 answers I was wondering if I'm safe from SQL injection if I have this in a script: < script> //some stuff var item = <?php echo json_oncode($PHPVAR) ?> item.replace(/"/,'&quot').replace(/'/,'&#39'); //do more script stuff with...

Laravel 5.1 Unable to Run Test on User Password Mutator

php,unit-testing,laravel,phpunit,laravel-5.1
I have a password mutator: /** * Mutator for setting the encryption on the user password. * * @param $password */ public function getPasswordAttribute($password) { $this->attributes[ 'password' ] = bcrypt($password); } That I'm trying to test: /** * A basic check of password mutator. * * @return void */ public...

Eloquent model not updating updated_at timestamp

php,laravel,timestamp,eloquent
I'm using Laravel 5.1. To make it simple, I have the following code Migration: Schema::create('sitemap_data', function (Blueprint $table) { // Primary and foreign keys $table->increments('id'); $table->string('postUrl'); // Database functions $table->timestamps(); }); And this is the code somewhere else I'm using $sitemapData = SitemapData::firstOrNew([ 'postUrl' => $post ]); $sitemapData->save(); Now, according...

How to create a migration in Laravel 5 that only adds a column to an existing table

php,mysql,laravel,migration,artisan-migrate
I'm trying to add a number of new column to the generic 'users' table that comes with the Laravel 5 installation. However I create a new migration that does a Schema::create as follows: Schema::create('users', function(Blueprint $table) { $table->increments('id'); $table->string('username'); $table->string('email')->unique(); $table->string('password', 60); $table->string('avatar'); $table->string('first_name'); $table->string('last_name'); $table->string('nickname'); $table->rememberToken();...

Admin login laravel 4

php,laravel
I edited the store method , now the problem is that when i try to login it redirect to www.example.com/admin but it shows a NotFoundHttpException. The routes.php file Route::get('/admin', [email protected]'); Route::get('/logout', [email protected]'); Route::get('profile', function() { return "welcome! Your username is" . Auth::admin()->username; }); Route::resource('sessions', 'SessionsController', ['only' => ['index', 'create', 'destroy',...

Given an array/object of datetimes, how can I return an array/object of the times sorted by hour and times sorted by days of the week

php,arrays,sorting,datetime,laravel
PHP/Laravel, I'm getting an array of objects that includes date times for each record. I need to generate analytics on objects on an hourly basis of a day and daily basis of a week. So for example: For a date range of 1/1/2015 - 1/10/2015 I return 100 records all...

Proper use of Array and Foreach at Laravel

php,laravel,laravel-4
I don't understand how to convert my PHP array into Laravel, I am new to Laravel and can't even find exact format to follow it. I would like to use it on my blade file. Here's my php code. $properties = array('office', 'retail'); foreach ($properties as $property) : echo $property;...

Remove index.php From Sub directory websites URL

php,.htaccess,laravel,mod-rewrite
I am currently in the process of moving a large number of subdomain websites to become sub directory websites. e.g. site1.website.com => website.com/site1. All of these sites use the same code in the same directory. The code will read the site name and load the correct database if it exists....

Bootstrap navbar toggle is not working with Laravel

jquery,html,css,twitter-bootstrap,laravel
I've following code <div class="container"> <div class="row"> <nav class = "navbar navbar-inverse navbar-fixed-top"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#topMenu" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a...

Laravel Production issue - Updating composer with Laravel 4.1.x

php,laravel,composer-php
I haven't encountered any issue in deploying my laravel project until now. I've been deploying for like almost a year already for this project. But some new bug came up. First of all. I can't run composer update, cause it says this error. composer update Warning: This development build of...

Setting up a second Homestead Laravel app

laravel,laravel-5,homestead
I've been trying to set up a second Laravel 5 app on my local Homestead space. I have been following the instructions from the official documentation and from this blog. (Although I have had to use the specific ID of the provision in order to get the vagrant provision command...

Laravel 4.2 Sending email error

php,email,laravel,laravel-4
Hello everyone I have an error in laravel when I am sending an email. I have a form with a select tag and when I select the user and click submit I need to send him a mail after I select it. Here is my Controller method: public function store()...

run laravel downloaded project on local machine

php,laravel,laravel-4
i am newbie trying to install an Laravel Framework project run on my local machine. Laravel Framework-4 already installed Package downloaded - https://github.com/mrakodol/Laravel-5-Bootstrap-3-Starter-Site now i get error when i try to compose please help me guys thanks in advance....

laravel 5.1 not seeing changes to Job file without VM restart

php,laravel,laravel-5,homestead
I have created a new Job in a laravel 5.1 app, running in Homestead VM. I've set it to be queued and have code in the handle method. The handle() method previous expected a param to be passed, but is no longer required and I've removed the param form the...

Laravel Dependency Injection with inheritance

php,laravel,dependency-injection
Let's say I have the following case: <?php abstract class Service { protected $config; public function __construct($config) { $this->config = $config; } } class ClientService extends Service { } class ProductService extends Service { } Is it possible to register in my service provider the dependency injection for the Abstract...

Reverse product list in Laravel

arrays,laravel,reverse
How can I reverse the product list in Laravel? Below is the code: public function index() { $products = Product::with('owner', 'memberInfo')->paginate($this->perPage); return View::make('layouts.sales', array('products' => $products, 'status' => 'all')); } ...

Laraver FindOrNew with multiple parameters

laravel
I'm using laravel FindOrNew() to get an entry with two parameters, or create a new one: $option = \App\Option::findOrNew(['user_id' => $this->id , 'option_name' => $optionName]); I want to get an option for a user that has the name in $optionName. The problem is that it just checks for the user_id,...

Laravel method attributesToArray() not running on production

php,laravel,laravel-5
I'm deploying my application to my production environment and it's not working as expected. I've narrowed the issue down to one line inside this loop in my controller; foreach($temp_table_data as $a_payment) { //array_push($payments, $a_payment->payment); //big collection object array_push($payments, $a_payment->payment->first()->attributesToArray()); //smaller object } The error I get is call to a...

Laravel use translator in a translation string

php,laravel,translation,translate,language-translation
Would it be possible to use trans() in a lang file? Eg: the line is Please fill in your :attribute Let's say :attribute is password. Would be possible to put password in the english lang file and then use wachtwoord in the dutch lang file for :attribute?...

Laravel 4 Pagination Buttons Not Working (Querying entire DB)

php,mysql,laravel,pagination
I'll start by saying i've already consulted the Laravel 4 documentation on Pagination and tried many methods to get this to work. I am using Eloquent together with Laravel 4's Pagination class. Problem: In my results page, i'm trying to paginate my results for what we'll call "trucks" DB. It...

Laravel 5 getting input values that are arrays

php,laravel,input,laravel-5,laravel-form
I have a text field like {!! Form::textarea('representive[address_1]' ,null ,['class' =>'textboxlong form-control','style'=>'height:60px;']) !!} In my form. And when i try to get its value in my controller but it comes null. What i try is $adress = Request::get('representive.0.address_1'); I also tried some other ways but could not end up with...

Update enum column in Laravel migration using PostgreSQL

postgresql,laravel,laravel-5,laravel-migrations
According to this answer, I have to run a raw query if I want to update an enum in MySQL. But with PostgreSQL, I can't use this query, and enum type for PostgreSQL in Laravel seems strange. Is there any way to update enum in a migration for postgreSQL ?...

How Do I call and pass data to a Directive from a Controller Angular

angularjs,laravel,angularjs-directive,controller
I have a QueueController.js which handles AJAX query. How do I pass the data from my CONTROLLER to my DIRECTIVE and show it to the Modal. Thanks. QueueController.js app.controller('QueueController', function($scope, $http, $interval, $modal) { $scope.Call = function(trans_id){ $http({ url: $locationProvider + 'query_stransaction', method: "GET", params: { trans_id: trans_id } }).success(function...

Create CRUD UI in reactjs with backend api

javascript,laravel,reactjs,react-router
Ive created a CRUD app in laravel, but now i want to improve the UI with react.js. Im still very new to react, so not sure how to go about doing this. So far i have created a table component that displays all the users with react. how should i...

Cannot get parameter value from url in main page

laravel,laravel-5
I searched a lot for the issue. But I couldn't find anything related to getting parameter value from get request in app.blade.php file. URL: http://localhost:8000/project/dashboard/1 I want to get this parameter value after user is signed in. Following is the code in AuthController. if ($this->auth->attempt($request->only('email', 'password'))) { return redirect()->route('dashboard', ['id'...

Get all files in a foreach loop in Laravel

php,jquery,laravel
I have some <input type="file"> that are generated dynamically by jQuery. That means that the name attribute of each input is also generated dynamically, is a number and increments by 1 every time a new input appears in the DOM. I need something like a foreach loop to get all...

Laravel 5: How to add Auth::user()->id through the constructor ?

authentication,laravel,constructor
I can get the ID of the authenticated user like this: Auth::user()->id = $id; Great it works, ... but I have a load of methods which need it and I want a cleaner way of adding it to the class as a whole,so I can just reference the $id in...

Retreiving a single colum from a pivot table - Laravel 5

php,laravel,eloquent,laravel-5
I am using a pivot table genre_user to relate user to genre. table contains the following fields id user_id genre_id Following are the model definitions User.php public function genres() { return $this->belongsToMany('App\Genre'); } Genre.php public function artists() { return $this->belongsToMany('App\User'); } I am getting the results as a collection when...

How to register global variable for my Laravel application?

php,laravel,laravel-5
I have started with Laravel a few days ago, and today I just installed the vespakoen/menu that seems to be very nice, and probably will work for what I need it. Currently I have installed Laravel 5.1 on my system. The problem I currently have, is where to register my...

Laravel put foreach inside mail

php,laravel,laravel-5,sendmail,swiftmailer
i want use a foreach inside my mail function, but i'm not sure how to do that, (i'm using swiftmailer, but that's not really relevant i think) here is my code: Mail::send('emails.bestelling', array( 'mededeling' => $bestelcode, 'rekeningnummer' => '000/000000/00', 'naam' => $userNaam, 'totaal' => $totaal, 'producten' => foreach ($mand as...

How to escape blade tags in laravel

php,laravel,blade
I'm working on a small CRM system where users need the option to send emails to other users and to load predefined templates. Currently the templates are stored in my views/emails/templates folder. Example: new_order.blade.php Inside the template I have the following code syntax: Visit us at: {{{ (isset($isTemplate) && $isTemplate)...

PDF as mail attachment - Laravel

laravel,pdf,sendmail
I want to create a PDF using the barryvdh/laravel-dompdf package and send this with an email as attachment. The code I have now is: $pdf = PDF::loadView('layouts.factuur', array('factuur' => $factuur)); Mail::queue('emails.factuur', array('factuur' => $factuur), function($message) use ($pdf) { $message->to(Input::get('email'), Input::get('naam'))->subject('Onderwerp'); $message->attach($pdf->output()); }); But now I get the following error: Serialization...

Laravel - Angular Routes

php,angularjs,laravel
I am trying to integrate angular with Laravel 5 and can't get the routes to show content from pages other then the index file. It is not picking up the route under .when() as I can change the templateURL and it has no effect. The files directory is as follows...

laravel 5 ->getRealPath() doenst show correct value

php,laravel,laravel-5,intervention
On my local development I use the code shown below, which works perfect, but when I uploaded the site to combell everything worked fine except my file upload. I already determined that the problem is involving ->getRealPath(), when I dd(); that I get this path: /data/sites/web/christophvhbe/tmp Which doesn't exist on...

Laravel 5 confirmation error message display in wrong field

laravel,laravel-5,laravel-validation
I would like to check if there is an error in my code I did not realize but why is my confirmation field's error message keep on displaying in the wrong filed? Suppose I have a password field and a password_confirmation field, but every time when user made a mistake...

Laravel 5 No query results for model redirect page

laravel,view,eloquent
I have simple form that post values to a controller,everything works fine if a result is returned from the controller , but if there is no result I get error the following error: No query results for model Which works as it should. My question is : Is it possible...

Laravel MethodNotAllowedHttpException

php,forms,exception,laravel,request
I am currently creating a website that, once the user arrives, they are greeted by a form with which they input their unique id and DoB. Upon entering the information and clicking submit, they are sent to the main form which has only a little information on it and the...

Laravel belongsTo throwing undefined function App/BelongsTo() exception

php,sql,laravel,eloquent,belongs-to
I have a comments table and user table with the relationship: user->hasMany('comments') and comment->belongsTo('user'). For some reason with which eludes me, I keep getting this FatalErrorException in Comment.php line 22: Call to undefined function App\belongsTo() My other models have no issue whatsoever with the HasMany relations, however, the comments model...

How to cut the content in laravel5?

php,laravel
I need to cut the characters that show description with the same quantity of letter in all foreach. Could anyone helps me? @foreach ($subastas as $subasta) @if(($subasta->data_inici <= $data)&&($subasta->data_final>$data)) <a href="item/{{$subasta->id}}"><div class="col-sm-4"> <div class="product-image-wrapper"> <div class="single-products"> <div class="productinfo text-center"> <div class="nombre">{{$subasta->nombre}}</div> @foreach ($subasta->images as $word =>...

Laravel 5: Redirecting woes

laravel
This line works in routes.php: Route::get('faq', [email protected]'); So I comment it out and try this: Doesn't work when the user is logged in. It will not redirect into the controller action that works in the aforementioned code: Route::get('faq', function() { if (Auth::check()) { return redirect()->action([email protected]'); } else { return Redirect::to('/');...

Only execute methods if session value laravel 5

php,laravel,laravel-5
I have a controller with alot of methods than should only be allowed to be executed if I have a certain value in my session. This is what I do at the moment: I made a private method that can either return the value 'yes' or 'no' Wich I call...

Can't get images from storage laravel 5

php,image,laravel
Hey so i'm trying to put my images into a slideshow i have on my index. the images are saved on storage/app , and then the rest of the path i retrive from my database. I managed to output the correct path on the <img src> tag, and the title...

Laravel 5 MethodNotAllowedHttpException

php,laravel,laravel-5,laravel-routing
I am using a form with PATCH method and I have a button link(since i already have a submit button and using same form for both store and update) as <a class="btn btn-default" href="{{ URL::to( 'pages/edit/' . $vehicle -> id) }}">EDIT</a> And my route is Route::patch('/pages/edit/{id}', ['uses' => [email protected]']); Controller...

Laravel 5 form request validation returning forbidden error

php,validation,laravel,laravel-4,laravel-5
I am trying to use Laravel 5.1's form request validation, to authorize if the request is from the owner. The validation is used when the user is trying to update part of the table clinics through the show.blade.php. My set up so far: routes.php: Route::post('clinic/{id}', array('as' => 'postUpdateAddress', 'uses' =>...

Laravel Blade: Increment variable by 1 each time?

php,laravel,laravel-4,blade
Using Laravel blade template, is there a way to include a variable and increase each time in the foreach or what is better approach? For example: @foreach($categories as $category) <li><a href="#tab_c1" role="tab" data-toggle="tab">{{$category->name}}</a></li> @endforeach In the foreach block, the value from #tab_c1 will need to be increase. eg: #tab_c1, #tab_c2,...

problems understanding workflow and set up of vagrant and laravel homestead

laravel,vagrant,virtual-machine,homestead
Up till now I've used a wamp server and thought I'd give Laravel Homestead a try as it's meant to be easier! I'm having problems getting the set up right and I'm confused about what I'm doing and where I should be doing them. I've got vagrant and virtual box...

Laravel relation many to many with additional pivot

php,laravel,laravel-4
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...

findOrFail laravel 5 function for specific filed

database,laravel,view,eloquent
This is my code: $get_all = Geo_Postal_us::findOrFail($postal); With this query,laravel try to find ID filed in table. I don't have id filed, for primary key i have postal column. So, how to set function to find value in postal column, not to search from id column ? Thanks,...

Laravel 5.2 Job with delay fires instantly instead of waiting

php,laravel,laravel-5,jobs
I'm creating an application with the Laravel 5.2 framework. In my application there is a job that I want to fire 2 days after the event. This is the code where an instance of the right job is made and where I set the delay to the amount of seconds...

Laravel: dynamic where clause with Elouquent

laravel,eloquent
I am calling URL with search params which are dynamic. How could I form proper Eloquent query? In theory: query query where(someParam1) query where(someParam2) query orderby(someParam3) query get I need this kind of structure so I can use where clause if param exists. If there is some other way in...

Laravel 5.1, Return response to user, then excute some code [closed]

php,android,laravel,android-gcm,laravel-5
The Story I am using NotificationPusher that uses GCM to send notification to user. It takes some time to connect to google server and wait for response. So, I don't want my user to wait until notification is sent, I want him to get the response (say that he successfully...

How can I Echoing Data After Checking For Existence in PHP Laravel 5?

php,laravel,laravel-5
I don't have anything store on my user phone field at the moment. <li><i class="md md-phone"></i> {{ $user->phone or 'No Phone' }} </li> So this line should print out No Phone. But instead it print out as blank. I'm confuse. What did I do wrong /forgot ? Is it because...

Laravel - Guzzle not returning any data even though URL is correct

php,laravel,laravel-4,laravel-5,guzzle
I am trying to return the JSON data from a third party API - http://postcodes.io/. I currently have in my controller: $client = new Client(); $request = $client ->get('https://api.postcodes.io/postcodes/'.Input::get('postcode')); $statusCode = $request->getStatusCode(); if ($statusCode >= 200 && $statusCode < 300) { $json = Response::json($request); // Returns JSON decoded array of...

custom orderBy() on constraining eager loads?

laravel,eager-loading
my question is about the possibilty of customizing Laravel's orderBy() method of the query builder, which i am using to sort an eager loaded dataset. This is the query scope I am using to generate the dataset. Everything works fine so far with this. public function scopeRestaurantsWithMenusToday($query, $city_uri){ return $query->where('city_uri',...

Getting code from my forked repository

git,laravel,repository,laravel-5,composer-php
I made a fork from a repository called "chrisbjr/api-guard". the repository latest version is v2.2.2, and I made a release v2.2.3 from my fork. I have my own branch which is dev-fulluth, to get the code from my fork not from the main repo, composer has to contain the below...

Laravel: Best practice for inline PHP in a blade file

php,laravel,laravel-5,blade
So I have the following blade file: confirmEmail.blade.php @extends('layouts.master') @section('title') {{ trans('tc.signUpConfirmTitle')}} @endsection @section('body') <div class="container"> <div class="row"> <div class="col-lg-4"> &nbsp; </div> <div class="col-lg-4"> <?php echo $_GET['emailToken']; $emailToken = isset($_GET['emailToken']) ? $_GET['emailToken'] : ""; $email = isset($_GET['email']) ? $_GET['email'] : ""; //database lookup: $user = User::where('email','=',$email)->first(); //this...

What does “as” keyword really mean in Laravel routing?

laravel,laravel-routing
as i understand by laravel documentation, its used for redirection, may be i am not right. i wrote Route::get('user/profile', ['as' => 'profile', function () { echo 'some_text'; }]); then i was expecting my url redicted from https://base_url/public/index.php/user/profile to https://base_url/public/index.php/profile but it doesn't happen. Overall i want to know, what is...

Error in laravel 4

php,laravel,laravel-4,login,admin
When i try to log in , it redirects me to www.example.com/admin/{username} but it shows a NotFoundHttpException error. Thank you in advance! The routes.php file Route::get('/admin', [email protected]'); Route::get('/logout', [email protected]'); Route::get('profile', function() { return "welcome! Your username is" . Auth::admin()->username; }); Route::resource('sessions', 'SessionsController', ['only' => ['index', 'create', 'destroy', 'store']]); here is...

Using framework event dispatcher to raise domain event

php,events,laravel,domain-driven-design,dispatcher
When i need to raise domain events, should i use framework specific Event Dispatcher or create my own Event Dispatcher that implemented by framework event dispatcher ? Since the framework has a really nice event dispatcher and the term of DDD said the domain layer should not dependent on any...

Laravel 5.1 PHPUnit with “use DatabaseMigrations;” Produces Error when Accessing Test DB

php,laravel,phpunit,laravel-5.1
I'm just learning PHPUnit with Laravel 5.1. I'm using "use DatabaseMigrations" to migrate the test database for each test, which I set in my phpunit.xml: <php> ... <env name="DB_DATABASE" value="project_test"/> ... </php> I've setup a bunch of basic tests as I go along to check instantiation, factories, etc, but I...

Physical delete a model which is enabled softdelete in laravel5?

php,mysql,laravel,laravel-5,soft-delete
I am using SoftDeletes for a model in Laravel5. But in some cases (Keeping history is not useful),I want to do physical delete (Removing row from table)instead of softDelete. class PaymentInvoices extends Model { use SoftDeletes; } Is there any method for forcing physical delete? ...