Menu
  • HOME
  • TAGS

Nested comments with Laravel

php,mysql,laravel,laravel-4

You want to look into polymorphic relations to solve this. You want to be able to comment on Posts and Comments. What I have done is set up a commentable trait and have the models I want to add comments to use it. This way if you ever want to...

Laravel 5 making a route for a specific link

laravel,laravel-5,laravel-routing

I had a similar problem trying to send a form directly to a route (using something like /pages/vehicles/61) but it seems to be imposible (question here). If you don't have a specific route for all vehicles (/pages/vehicles doesn't show a list of vehicles) you can do something like: Route::get('pages/vehicles','[email protected]'); And...

Laravel 5: Redirecting woes

laravel

You are trying to route something within a route definition itself. That is not how it works. There are a few ways you could do what you want to achieve. There are pros/cons to each - but they would all work. Generally the best way is to use some Auth...

Laravel 5 confirmation error message display in wrong field

laravel,laravel-5,laravel-validation

because you have defined confirmed rule for your password field, all the errors related to password_confirmation will also be shown in password field.

Laravel 5.2 Job with delay fires instantly instead of waiting

php,laravel,laravel-5,jobs

The issue ended up being the queue driver (in config/queue.php) was set to 'synchronous'.

Physical delete a model which is enabled softdelete in laravel5?

php,mysql,laravel,laravel-5,soft-delete

Of course there is. Use forceDelete method instead of just delete. Keep in mind, forceDelete is only available if you use the SoftDeletes trait. Example $instance->delete() //This is a soft delete $instance->forceDelete() // This is a 'hard' delete More info here (scroll down to Permanently Deleting Models)...

Update resource AJAX Laravel 5

php,jquery,ajax,laravel

You aren't preventing default from happening when you click the submit button which is preventing the AJAX from completing and forcing it into the error method each time. It also explains why in your PHP, the $request->ajax() is returning false. form.bind('submit',function(e) { e.preventDefault(); $.ajax({ type: form.attr('method'), url: form.attr('action'), data: form.serialize(),...

Error homestead up

laravel,vagrant,homestead

I think it's because the # not in correct way. it should be like --- ip: "192.168.10.10" memory: 2048 cpus: 1 provider: virtualbox authorize: ~/.ssh/id_rsa.pub keys: - ~/.ssh/id_rsa folders: - map: ~/Projects to: /home/vagrant/Projects sites: - map: myawesomeproject.app to: /home/vagrant/Projects/Laravel/public databases: - homestead variables: - key: APP_ENV value: local #...

Laravel method attributesToArray() not running on production

php,laravel,laravel-5

One of the tempTable models doesnt have a Payment and the attributesToArray() method is failing. Try this and see if it works. foreach($temp_table_data as $a_payment) { $payment = $a_payment->payment->first(); if(!is_null($payment)){ $payments[] = $payment->attributesToArray(); } } ...

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

php,laravel,laravel-5

{{ $var or 'No Phone' }} === {{ isset($var)? $var : 'No Phone' }} Because $user->phone is defined you should use this: {{ $user->phone? $user->phone : 'No Phone' }} Or, you can go nice Laravel way and create your own directive for Blade templates and use it like this: @var($user->phone,...

Laravel 5 not storing checkbox value

php,laravel,checkbox,laravel-5

Have you put the field 'optin' in the $fillable array within the model? Otherwise you cant create a User with 'optin' using the static create method. //File: User.php protected $fillable = ['optin']; ...

Laravel: dynamic where clause with Elouquent

laravel,eloquent

It's easy with Laravel. Just do something like this: $query = User::where('created_at', '>', '2010-01-01'); if (this == that) { $query = $query->where('this', 'that); } if (this == another_thing) { $query = $query->where('this', 'another_thing'); } $results = $query->get(); ...

Laravel relation many to many with additional pivot

php,laravel,laravel-4

As per your requirement, I blieve you have to update your relation to Polymorphic Relations. and than to access other attributes try one of them method. $user->roles()->attach(1, ['expires' => $expires]); $user->roles()->sync([1 => ['expires' => true]]); User::find(1)->roles()->save($role, ['expires' => $expires]); If you still facing some dificulties to handle that requirement let...

Laravel get posts with multiple tags

php,sql-server,laravel,eloquent

It would be a good idea to use whereHas() on the Post model to eager load the tags and get only the Posts which have at least one of those tags. $posts = Post::whereHas('tags', function($q) use ($tags) { $q->whereIn('id', $tags); })->get(); Here, $tags would just be an array of tag...

Laravel Collection installation with Composer and Laravel 5

laravel,composer-php,laravel-collection

Actually, the error messages are clear. You are trying to install a package that has a dependency of laravel componenents with a version of 5.1, but in your composer.json file, you imply that your project works with laravel 5.0. Either change the laravelcollective/html version to 5.0.* or change and upgrade...

findOrFail laravel 5 function for specific filed

database,laravel,view,eloquent

You could create the behaviour you are looking for with the following: Geo_Postal_us::where('postal', $postal)->firstOrFail(); ...

Laravel: Retrieve polymorphic attributes efficiently

rest,laravel,polymorphism,eloquent

You might be almost there. Your getAvatarAttribute() is way too complicated, indeed. You could try to do something like: /** we hide the relation from the json */ protected $hidden = ['avatar']; /** we append the url of the avatar to the json */ protected $appends = ['avatar_url']; /** *...

Sync element to a child on Laravel

php,mysql,laravel,eloquent,laravel-5

As far as syncing/attaching you can use this sytanx $user->roles()->sync([1, 2, 3]); As given in Laravel Docs You can do the both checks in the condition of IF and assign in case of true, thats how your controller will look like finally. public function share(Request $request) { $userId = $request->input('user_id');...

laravel 5.1 not seeing changes to Job file without VM restart

php,laravel,laravel-5,homestead

When running the queue worker as a daemon, you must tell the worker to restart after a code change. Since daemon queue workers are long-lived processes, they will not pick up changes in your code without being restarted. So, the simplest way to deploy an application using daemon queue workers...

Messed up a merge when trying to upgrade my Laravel application

git,laravel,github,merge

When you did the git reset --soft HEAD~1, you "moved backwards" a commit, while keeping your working directory and index the same. So when you committed, the files were changed as if you had done the merge, without doing an actual merge; i.e., your commit had only one parent. I'm...

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

php,laravel,laravel-5,laravel-middleware

Middleware might be an option. Alternatively could you do this in the constructor of your BaseController? E.g. class BaseController extends Controller { public function __construct() { //if token in query string //load Job and check status Vs requested URL //redirect to correct URL } } ...

run laravel downloaded project on local machine

php,laravel,laravel-4

From PHP.net: Windows users must include the bundled php_fileinfo.dll DLL file in php.ini to enable this extension. Check your php.ini file to ensure the .dll file is listed. The line is probably there and looks like ;extension=php_fileinfo.dll so just remove the ;....

Laravel Blade: Increment variable by 1 each time?

php,laravel,laravel-4,blade

Add iterator to @foreach: @foreach($categories as $key => $category) <li @if ($key === 0) class="active" @endif> <a href="#tab_c{{$key+1}}" role="tab" data-toggle="tab"> {{$category->name}} </a> </li> @endforeach {{$key+1}} in my example because in PHP iterator starts at 0....

How to escape blade tags in laravel

php,laravel,blade

You can use the @{{ to escape a blade syntax. So you could use '@{{ $offerUrl }}' ...

Create CRUD UI in reactjs with backend api

javascript,laravel,reactjs,react-router

So to answer your two questions: React-router is pretty simple to use, and the documentation is great. You just have to create the different routes you want on the client-side. In your case you going to have three routes. The best is really to check the documentation which is really...

Error in laravel 4

php,laravel,laravel-4,login,admin

You haven't declared any routes pointing to /admin/{username} . That's the reason it can't be found by laravel. Here is an example: In your route files Route::get('/admin/{username}', '[email protected]'); I strongly advice you to use named routes. They are a lot easier to manage, even if your application gets bigger. For...

Setting up a second Homestead Laravel app

laravel,laravel-5,homestead

The problem was in your homestead.yaml file. folders: - map: C:\Users\Lisa\Documents\Homestead\larapipeline to: /home/vagrant/Code/larapipelin - map: C:\Users\Lisa\Documents\Homestead\tinkertower to: /home/vagrant/Code/tinkertower sites: - map: homestead.app to: /home/vagrant/Code/larapipeline/public - map: tinkertower.app to: /home/vagrant/code/tinkertower/public Don't forget to edit your hosts file. Now run vagrant up --provision, or vagrant reload --provision. Edit: Fixed case sensitivity issue...

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

You can use Laravel's collection groupBy method to group your records for your needs. $records = YourModel::all(); $byHour = $records->groupBy(function($record) { return $record->your_date_field->hour; }); $byDay = $records->groupBy(function($record) { return $record->your_date_field->dayOfWeek; }); Remember that this code to work, you have to define your date field in the $dates Model array, in...

Laravel belongsTo throwing undefined function App/BelongsTo() exception

php,sql,laravel,eloquent,belongs-to

Well, this error occurred because I had '.' in place of '->'. I couldn't figure out why it was always throwing the exact same error regardless if I did $this.belongsTo('App\User'); or $this.hasMany('App\User'); or even $this.thecakeisalie('App\User'); until I sat staring at the text between my many models yet again. Then, lo...

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

angularjs,laravel,angularjs-directive,controller

It looks like it's going to be something reused so I'd strongly suggest to use service/factory I've made few examples for you of the way to pass data to directive app.service('postService', function postService($http) { var postDataMethod = function (formData) { $http.post('http://edeen.pl/stdin.php', formData) .success( function (data) { service.response = data })...

Set options for ZADD command in laravel redis

php,laravel,redis,set

Until Predis' zAdd method is updated to support the changes in Redis v3.0.2, your best bet is to explore the wonderful world of RawCommand: https://github.com/nrk/predis/blob/master/src/Command/RawCommand.php It should let you construct your own commands, including the ZADD NX ... variant....

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

authentication,laravel,constructor

You can use Auth::user() in the whole application. It doesn't matter where you are. But, in response to your question, you can use the 'Controller' class present in your controllers folder. Add a constructor there and make the reference to the user ID. <?php namespace App\Http\Controllers; use Illuminate\Foundation\Bus\DispatchesCommands; use Illuminate\Routing\Controller...

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

php,mysql,laravel,migration,artisan-migrate

From http://laravel.com/docs/5.1/migrations#creating-columns Creating Columns To update an existing table, we will use the table method on the Schema facade. Like the create method, the table method accepts two arguments: the name of the table and a Closure that receives a Blueprint instance we can use to add columns to the...

Get base_url using Jquery in Laravel

jquery,laravel,laravel-5

Do you mean you want the base url of your laravel app available anywhere your javascript? You can include this in your template.blade.php: <script type="text/javascript"> var APP_URL = {!! json_encode(url('/')) !!}; </script> And than access that var anywhere in your javascript: console.log(APP_URL); ...

Remove index.php From Sub directory websites URL

php,.htaccess,laravel,mod-rewrite

Set a RewriteBase for the new folder, like so: RewriteEngine On RewriteBase /site1/ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] ...

Laravel trans helper function not picking the right file

php,laravel,translation,language-translation,registrar

To make this work you need to use a middleware to set Locales: Create a LocaleMiddleware.php inside app/http/middleware directory //LocaleMiddleware.php <?php namespace App\Http\Middleware; use Closure; use Illuminate\Session\Store as Session; use Illuminate\Contracts\Auth\Guard as Auth; class LocaleMiddleware { public function __construct(Session $session) { $this->session = $session; } //Languages available in your resources/lang...

Laravel validator vs requests

laravel,laravel-5,laravel-validation

1. Theoretically there is no difference between Controller validation and Validation using FormRequest. Normally you should use FormRequest. This will keep your controller clean and Minimal. But some time it is sensible to use Validator within controller, e.g you know there is going to be just one field to validate,...

Eloquent model not updating updated_at timestamp

php,laravel,timestamp,eloquent

As mentioned in comments, if the model did not change the timestamps wont be updated. However if you need to update them, or want to check if everything is working fine use $model->touch() - more here

Getting code from my forked repository

git,laravel,repository,laravel-5,composer-php

Having a look at your repository in https://github.com/Yunishawash/api-guard it looks like it doesn't have a branch called dev-fullauth. Instead there is a branch dev-bugfix. But you must not name your branch including the dev- prefix. Rename your branch at github from dev-bugfix to bugfix and then your require section would...

Admin login laravel 4

php,laravel

In your admin template you set the goto url as sessions.store which hits SessionsController::store in that method you have a debug function dd() which is throwing that string. It get's called because auth::attempt() returns false as by your own code: if($attempt) return Redirect::intended('/'); So the behavior is exactly doing what...

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

javascript,php,jquery,laravel,laravel-5

I solved it by doing this HTML {!! Form::model($user, array('route' => array('user.update_profile_picture', $user->id ),'method' => 'PUT')) !!} <a class="pmop-edit" > <span id="file-upload" > <i class="md md-camera-alt"></i> <span class="hidden-xs">Update Profile Picture</span> </span> <div style='height: 0px;width: 0px; overflow:hidden;'> <input id="upfile" type="file" value="upload" onchange="sub(this)" /> </div> </a> {!! Form::hidden('$id', $user->id)!!} {!!...

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

php,laravel,laravel-4,laravel-5,guzzle

What you are seeing is the raw response back from Guzzle and it needs to be formatted. A simple way is $response->getBody();. Think of this like a collection in Laravel. When you get the data back, it is in a collection with a bunch of extra data that may be...

Bootstrap navbar toggle is not working with Laravel

jquery,html,css,twitter-bootstrap,laravel

What the problem is is that you are using the link tag where you actually should be using the script tag: <link rel="text/javascript" href="{{ URL::asset('assets/js/jquery.js') }}" /> <link rel="text/javascript" href="{{ URL::asset('assets/js/bootstrap.min.js') }}" /> Javascript should be in a script tag for it to load into your page: <script type="text/javascript" src="{{...

Laravel Interfaces

php,laravel,interface,namespaces

In my recent laravel 5 project, I'm used to prepare my logics as Repository method. So here's my current directory structure. For example we have 'Car'. So first I just create directory call it libs under app directory and loaded it to composer.json "autoload": { "classmap": [ "database", "app/libs" //this...

custom orderBy() on constraining eager loads?

laravel,eager-loading

Something like this may work... the idea is to add an additional select which is 0 or 1 depending on if the date is today. Then you can order by that column first, then the actual date second. public function scopeRestaurantsWithMenusToday($query, $city_uri){ return $query->where('city_uri', '=', $city_uri)->with([ 'restaurants', 'restaurants.menusToday' => function($query)...

Laravel MethodNotAllowedHttpException

php,forms,exception,laravel,request

It looks to me your problem is the url in our routes. You are repeating them. Firstly I would recommend using named routes as it will give you a bit more definition between routes. I'd change your routes to Route::put('jurors/submit',[ 'as' => 'jurors.submit', 'uses' => '[email protected]' ]); Route::get('jurors',[ 'as' =>...

Handling 500 Internal Server Error from DomDocument in Laravel 5

php,laravel,exception-handling,laravel-5

You could handle this in Laravel app/Exceptions/Hnadler.php NB: I have looked in the option of using DOMException handler which is available in PHP, however the error message you are getting in not really and exception by an I/O Warning. This what PHP native DomException looks like: /** * DOM operations...

Laraver FindOrNew with multiple parameters

laravel

TL;DR: You're using the wrong method. You're looking for the firstOrNew() method, not findOrNew(). Explanation: The findOrNew() is an extension of the find() method, which works on ids only. It takes two parameters, the first being the id (or array of ids) to find, and the second being the columns...

Laravel 5 form request validation returning forbidden error

php,validation,laravel,laravel-4,laravel-5

You are getting Forbidden Error because authorize() method of form request is returning false: The issue is this: $clinicId = $this->route('postUpdateAddress'); To access a route parameter value in Form Requests you could do this: $clinicId = \Route::input('id'); //to get the value of {id} so authorize() should look like this: public...

Get a simple boolean value from a GET request using jQuery

jquery,ajax,laravel

You need to make sure to send a JSON response from that route. Otherwise you're making it yourself harder. As there's not much code to work with, I'll try to explain it in a generic way... Create the route (you've already done that). A get route is just fine for...

Only execute methods if session value laravel 5

php,laravel,laravel-5

Of course there is a better way. You are looking for a Middleware. First, create one: php artisan make:middleware SessionMiddleware Edit the file you just created: public function handle($request, Closure $next) { if (SESSION_KEY_IS_NOT_OK) { abort(403); } return $next($request); } Register it by editing your app/Http/Kernel.php file protected $routeMiddleware =...

laravel 5 and Ajax get data from database:

ajax,laravel,views

It appears you're passing your ajax method a variable that doesn't exist. Try passing it the form data directly and see if that yields any results, you can do this with the serialize method: $("#frm").submit(function(e){ e.preventDefault(); var form = $(this); $.ajax({ type: "POST", url : "http://laravel.test/ajax", data : form.serialize(), dataType...

Can't get images from storage laravel 5

php,image,laravel

What you are trying to do is not possible in the storage directory but possible only in public directory, also exposing the path or URL to your laravel storage directory creates some vulnerability and its bad practice However there is a way to workaround it: First, you need an Image...

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

php,mysql,security,laravel,pdo

The question is somewhat unanswerable (atleast not in a way that will not give you a false sense of security) with the amount of resource provided. Since you are using PDO I'll go right ahead and say that you ought to be using prepared statements. Injection on a whole primarily...

Get all files in a foreach loop in Laravel

php,jquery,laravel

You need to create a Form for multiple File uploads: {!! Form::open(array('url'=>'url_to_controller','method'=>'POST', 'files'=>true)) !!} And all your files should have a specfic name for the upload, like this: {!! Form::file('files[]', array('multiple'=>true)) !!} Then you can use your Controller: class UploadController extends Controller { public function store() { $files = Input::file('files');...

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

php,android,laravel,android-gcm,laravel-5

You may use queue. When user comment post, add event to queue. Queue is parsed by cron (using Laravel's command).

Laravel 5 pagination with trailing slash redirect to 301

php,laravel,redirect,pagination,laravel-5

If you look in your app/public/.htaccess file you will see this line: # Redirect Trailing Slashes... RewriteRule ^(.*)/$ /$1 [L,R=301] By removing it you will disable trailing slash redirect....

Update enum column in Laravel migration using PostgreSQL

postgresql,laravel,laravel-5,laravel-migrations

Laravel use constraint on character varying for enum. Assuming there is a table mytable with an enum column status, we have to drop the constraint (named tablename_columnname_check) then add it in a migration like this: DB::transaction(function () { DB::statement('ALTER TABLE mytable DROP CONSTRAINT mytable_status_check;'); DB::statement('ALTER TABLE mytable ADD CONSTRAINT mytable_status_check...

Reverse product list in Laravel

arrays,laravel,reverse

You can use Eloquent's reverse() function for collections. public function index() { $products = Product::with('owner', 'memberInfo'); $products = $products->reverse()->paginate($this->perPage); return View::make('layouts.sales', array('products' => $products, 'status' => 'all')); } ...

How to change default Nginx setting on Homestead Laravel Virtualbox VM

laravel,nginx,vagrant,virtualbox,homestead

Easiest way to achieve this is editing scripts/serve.sh file, which contains server block template in block variable.

Retreiving a single colum from a pivot table - Laravel 5

php,laravel,eloquent,laravel-5

I think what will help you achieve this behavior is the lists() method. Try something like $user_genres = auth()->user()->genres()->lists('name','id'); If you are using Forms & HTML package you can just do {!! Form::select('genres',$user_genres,null) !!} And here is your dropdown More info here (scroll down to "Retrieving A List Of Column...

Laravel Production issue - Updating composer with Laravel 4.1.x

php,laravel,composer-php

Eventually you can install php DOM extension. Certain Linux distributions do not have this extension included in the minimum PHP package. It can usually be found in one of the "optional" php-* packages. On CentOS you should be able to just run yum install php-dom or yum install php-xml. That...

Redirect to Login page if ther user not logged in Laravel

laravel,laravel-5,laravel-routing

You can put as many routes in a Group as you like to Route::group(array('before' => 'auth'), function(){ Route::get('/', '[email protected]'); Route::post('store', '[email protected]'); Route::get('show', '[email protected]'); // ... }); If you really need to protect all your routes, you could add public function __construct() { $this->middleware('auth'); } To your main controller class, Http/Controllers/Controller...

Laravel 5.1 throws ReflectionException after upgrade from 5.0

laravel,laravel-5

OK, I found the solution. I noticed that if in GetRequest class I swap use App\Http\Requests\Request; with use Request; then the GetRequest class is found and the ReflectionException is not thrown anymore. So the problem is not in the App\Http\Requests\User\GetRequest class but in the abstract class App\Http\Requests\Request. After looking at...

Getting an image to render with php

php,image,laravel,image-processing

The code is working - the problem is it's sending extra information. The file is there, it is found, it is being sent. The link to your image returns: HTTP/1.1 200 OK Date: Wed, 17 Jun 2015 22:52:03 GMT Server: Apache Connection: close Content-Type: image/jpeg But the subsequent output is...

count() “where” statement in Laravel blade?

laravel,laravel-4,blade

You can count a relationship like this: $emails->mandrillemails()->whereMsgState('bounced')->count(); Since you're @foreaching things, you may want to eager load this data. This is a little more complex when you're doing counts on the relationship - see http://laravel.io/forum/05-03-2014-eloquent-get-count-relation and http://softonsofa.com/tweaking-eloquent-relations-how-to-get-hasmany-relation-count-efficiently/ for some possible techniques to eager-load the count value instead of the...

Laravel put foreach inside mail

php,laravel,laravel-5,sendmail,swiftmailer

Use foreach outside Mail() as below : $production_string = ''; foreach ($mand as $rij) { $production_string .= "Name : ".$rij->name; $production_string .= ", Quantity : ".$rij->qty; } Mail::send('emails.bestelling', array( 'mededeling' => $bestelcode, 'rekeningnummer' => '000/000000/00', 'naam' => $userNaam, 'totaal' => $totaal, 'producten' => $production_string } ), function($message) { $message->from('[email protected]'); $message->to('[email protected]',...

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

php,laravel,query-builder

The first() method will always return one result or null if no results are found. Here's all it does: public function first($columns = array('*')) { $results = $this->take(1)->get($columns); return count($results) > 0 ? reset($results) : null; } The difference to just using take(1) (or limit(1)) is that it actually just...

Using framework event dispatcher to raise domain event

php,events,laravel,domain-driven-design,dispatcher

Lately I favor returning events from domain methods and handling those in the application service layer. Since the application service layer is where you bring together all kinds of infrastructure further processing of the returned events, such as dispatching, can be handled in the application service layer. In this way...

Android post request in php

php,android,laravel,post

I think I found the problem, and think I can help others with it too. I was using Laravel to call the function but apparently Laravel didn't like that. I downloaded a Chrome tool called Postman and sent a Post request manually which threw an error, maybe to prevent Cross-site...

problems understanding workflow and set up of vagrant and laravel homestead

laravel,vagrant,virtual-machine,homestead

Are you using cygwin? You should run the commands inside the Homestead folder which is created after you do homestead init. Then you do the configuration or mapping of folders in your Homestead.yaml. it is located in you home directory. in my case in created a .homestead folder. I'm using...

How to delete only the table relationed

sql,laravel,migration

When creating a foreign key constraint, you can also decide what should happen with the constraints. For instance, if you want to delete all articles when a category is deleted (as I guess is your question): Schema::table('articulos', function($table) { $table->foreign('categoria_id')->references('id')->on('categorias')->onDelete('cascade'); $table->foreign('creador_id')->references('id')->on('users'); }); Also see documentation. The cascade identifies to the...

Deleting migrations results in an Exception

php,laravel,laravel-5,composer-php,autoload

Go into your mysql database manually (PHPMyAdmin) and remove the migrations table. With the steps you've taken above and doing this should solve your issue

laravel file uploading using json

jquery,ajax,json,laravel,laravel-5

Use this as your code: e.preventDefault(); var mydata = new FormData($('#my_form')[0]); $.ajax({ type: 'POST', cache: false, dataType: 'JSON', url: 'tasks', data: mydata, processData: false, contentType: flase success: function(data) { console.log(data); }, }); Note that this doesn't work on some older browsers such as IE 9 or older so you might...

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

php,laravel,eloquent,laravel-5,accessor

FormBuilder use object_get() helper function for get value from model: /** * Get the model value that should be assigned to the field. * * @param string $name * @return string */ protected function getModelValueAttribute($name) { if (is_object($this->model)) { return object_get($this->model, $this->transformKey($name)); } elseif (is_array($this->model)) { return array_get($this->model, $this->transformKey($name)); }...

Restrict laravel to open url that is not in route

php,laravel,routing,laravel-5,laravel-5.1

This is because you access your site from http://localhost. Every file and folder that is inside your root folder is accessible via the browser. So don't run your project from localhost but from a proper virtual host. For example make http://project.dev and use that to access your site <VirtualHost *:80>...

Proper use of Array and Foreach at Laravel

php,laravel,laravel-4

Try as below : <?php $properties = array('office', 'retail'); ?> @foreach ($properties as $property) {{{ $property }}} @endforeach ...

Payum Laravel Package - Route not found

laravel,nvp

My suspicion is that the third parameter is expecting a route name, not a URL. Your routes.php route is not a named route. Route::get('done', ['as' => 'done', 'uses' => '[email protected]']); ...

PhpStorm - wrong syntax highlighting with Blade

laravel,syntax-highlighting,phpstorm,blade

Settings (Preferences on Mac) | Editor | File Types Text files Find and get rid of unwanted pattern (most likely will something be similar to layout.blade or alike. ...

Laravel: Best practice for inline PHP in a blade file

php,laravel,laravel-5,blade

Is using raw PHP like this defeating the whole purpose? Exactly ! MVC are made so that there will be different layers of different type of job Model, View and Controller here in your case you are combining the job of controller into a view and hence diminishing the role...

Laravel5: Access public variable in another class

php,class,oop,laravel,laravel-5

That's simple php stuff. Set the attribute as static and access it with ::. class LanguageMiddleware { public static $languages = ['en','es','fr','de','pt','pl','zh','ja']; } @foreach (App\Http\Middleware\LanguageMiddleware::$languages as $lang) ... @endforeach You should not have that in a middleware though. You'd better add a configuration (i.e in /config/app.php) with that array, and...

Using Twigbridge in a Laravel 5.1 Package

laravel,twig

Sorry to answer my own question, but I found out the answer was to reference the package. So {% extends 'folder.file' %} becomes {% extends 'packagename::folder/file' %}. That successfully loads the file but it does not answer how to get functions like {{ form_text() }} to work. Since I'm using...

How to register global variable for my Laravel application?

php,laravel,laravel-5

Actually, you should reserve in config/app.php file. Then, you can add In the Service Providers array : 'Menu\MenuServiceProvider', In the aliases array : 'Menu' => 'Menu\Menu', Finally, you need to run the following command; php artisan dump-autoload I assume that you already added this package in composer.json Sorry, I didn't...

Cannot get parameter value from url in main page

laravel,laravel-5

You can do: Route::getCurrentRoute()->getParameter('id') See Illuminate\Routing\Route.php /** * Get a given parameter from the route. * * @param string $name * @param mixed $default * @return string|object */ public function getParameter($name, $default = null) { return $this->parameter($name, $default); } ...

Laravel use translator in a translation string

php,laravel,translation,translate,language-translation

You can use language specific attributes for this inside of your language validation file lang/nl/validation.php in the attributes array for example: 'attributes' => [ 'name' => 'naam' 'password' => 'wachtwoord' ], This will translate those attributes globably on all forms. for a broader explanation check: Laravel validation attributes "nice names"...

PDF as mail attachment - Laravel

laravel,pdf,sendmail

You can only send serializable entities to the queue. This includes Eloquent models etc. But not the PDF view instance. So you will probably need to do the following: Mail::queue('emails.factuur', array('factuur' => $factuur), function($message) { $pdf = PDF::loadView('layouts.factuur', array('factuur' => $factuur)); $message->to(Input::get('email'), Input::get('naam'))->subject('Onderwerp'); $message->attach($pdf->output()); }); ...

How to cut the content in laravel5?

php,laravel

Do you mean you want to limit the number of characters in a string? This can be done in laravel by a string helper: $value = str_limit('The PHP framework for web artisans.', 7); So in your example: <p>{{ str_limit($subasta->descripcion, 20) }}</p> ...

Join this eloquent laravel5

php,laravel

The relation is a hasMany and will therefor return a collection set, not one "echoable" thing: $mensajes = Messageuser::find(1)->conversaciones()->get(); $mensajes2 = Messageuser::find(4)->conversaciones()->get(); \dd($mensajes, $mensajes2); This will return two Collection objects dumped. Please also note that you can use: $mensajes = Messageuser::find(1)->conversaciones; To get the same return set. Now you want...

Laravel 5 No query results for model redirect page

laravel,view,eloquent

Suggestion 1 $postal = $request->input('postal'); $get_all= Geo_Postal_us::where('postal', $postal)->first(); if($get_all) { $count=count($get_all); return view('test.show',compact('get_all','count')); } return Redirect::back()->with('message','No results found'); This will check if get_all is found and if is found will return test.show view else will redirect to previous view with message No results found . If you want to declare...

Laravel Dependency Injection with inheritance

php,laravel,dependency-injection

In your example, you have to manually pass the config object every time you instantiate from Service class or a child class. So when you want to directly instantiate a child service, you could use something like, $cs = new ClientService(new Config()); However, you can use the real advantage of...

Laravel 4.2 Sending email error

php,email,laravel,laravel-4

Closures work just like a regular function. You need to inject your outer scope variables into function's scope. Mail::send('invoices.mail', array($pinvoices,$unpinvoices), function($message) use ($email) { $message->to($email , 'Name')->subject('your invoices '); }); ...

Laravel - Angular Routes

php,angularjs,laravel

I had similar problem. I modified the render function in app\Exceptions\Handler.php to public function render($request, Exception $e) { if ($e instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) { return response()->view('index'); } return parent::render($request, $e); } and created an index.blade.php view in resources\views folder, which was like <?php include public_path().'/views/index.html'; and it contains all the angular...