Menu
  • HOME
  • TAGS

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...

Adding to a collection?

laravel,laravel-4,eloquent,laravel-5

Just lunch method on existing object: $data->splice(5, 0, [$firstProduct]); (don't rewrite the object itself) Additionaly, use brackets on added element: [$firstProduct] to prevent casting this element to an array and adding all its fields to collections instead of whole object....

Laravel 4.2: After checking “remember me” checkbox user's login doesn't get remembered in database, only in cookie, thus remember me not working

php,authentication,cookies,laravel-4

Please notice that remember_token only makes sure that the user won't be logged out after 2 hours (or any other amount of time that has been given in the config file). You need to have a user model before it will work. The fillable variable tells the model which fields...

Wordpress blog + Laravel with SEO friendly urls

php,wordpress,apache,.htaccess,laravel-4

So long as you have the following two files, you should be just fine: DOCUMENT_ROOT/.htaccess (where the document root is your Laravel public directory): RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ index.php [L] DOCUMENT_ROOT/blog/.htaccess: RewriteEngine on RewriteBase /blog/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ index.php...

Permission denied error on CSV export Laravel

csv,laravel,laravel-4,permission-denied

Finally I found the problem. The file.csv is created inside the current working directory. Which is the root directory that don't have the write permission. To fix this permission I give write permission to the folder....

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....

is it possible to email a particular piece of data from database without using view?

laravel-4

You cant have blade variables within other variables - it doesnt work that way. You need to change your code to this: Mail::send('blank', array('msg' =>'Welcome '.e(Input::get('name')),'name'=>Input::get('name'),'confirmation_code' => $confirmation_code), function($message){ $message->to(Input::get('email'), Input::get('name'))->subject(' '); }); Or better yet - handle the message inside the view file itself, rather than passing it via...

Id Column Overwritten by Join

php,mysql,laravel,laravel-4,eloquent

I was able to find a possible solution using this answer: Laravel 4 - JOIN - Same column name Basically, since Laravel does not automatically prefix column names with table_name. for joined tables, we need to manually work around it by aliasing any conflicting column names in joins. Adding this...

Laravel 4 inside Wamp does not work

php,laravel-4

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);//This is line 50 the ::class is only supported since PHP 5.5 Also you must have mistakingly installed laravel 5.1+ because that's the only version to require php 5.5+...

Laravel 4 to Microsoft SQL server remote

sql-server-2008,ubuntu,laravel-4,ubuntu-12.04

As your SQL Server database is on a remote server, let's say 192.168.1.23 replace the 'host' field value with 192.168.1.23 and your SQL Server credentials on the 'username' and 'password' fileds, let's say username: sa and password: asecurepassword 'sqlsrv' => array( 'driver' => 'sqlsrv', 'host' => '192.168.1.23', 'database' => 'your_database_name',...

Trying to figure out a how call works in twilio

php,laravel-4,twilio,twilio-php,twilio-click-to-call

Twilio evangelist here. I would suggest working through the Twilio Client for JavaScript Quickstart. This will walk you through both the server and client side code needed to build a phone in your browser, showing you how to both make outbound calls from the browser to a PSTN phone as...

Matched data inside select supposed to selected by default

laravel,if-statement,laravel-4,foreach,blade

You can do: <option {!! ($dev->id == $project_development->developer) ? 'selected' ? '' !!} value="{{ $dev->id }}"> {{ $dev->name }} {!! ($dev->id == $project_development->developer) ? '(Current Status)' ? '' !!}</option> ...

Node.js with Laravel 4.2

php,node.js,amazon-web-services,laravel-4,ratchet

I tried many ways to integrate Nodejs with my application, but finally I used Faye. I put my code on following link. Node js Faye Client not working properly with HTTPS This work fine. If you have another solutions, You are welcome...

Attachment downloaded in “File” format instead of pdf

pdf,laravel-4,email-attachments,file-format

Found the solution. Add .pdf with the file name in as attribute, like this: $message->attach( $invoice_path, array('as' => 'Invoice-' . $transaction->id. ".pdf", 'mime' => 'application/pdf') ); ...

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...

Self Join in Eloquent - How To Call

laravel,laravel-4,eloquent,laravel-5

I believe your relations are not the way they're supposed to be. Usually it's one column (foreign key - color_id in your case) having a value of the other one (usually primary key - id in your case). What you have is basically a value the records share or a...

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...

Array passed into class constructor is empty - Cannot access empty property

php,class,oop,laravel-4

Your issue: public function foo() { dd($this->$date); } needs to be public function foo() { dd($this->date); } ...

How to Retrieve data form many to many relation in laravel4?

php,mysql,laravel-4,eloquent

Try this. Service::whereHas('tag', function($query) use ($tagId) { $query->where('tag_id', '=', $tagId); })->get(); Edit: Changed the answer. Previous Answer: Business::with(['services')->whereHas('tag', function($query) use ($tagId) { $query->where('tag_id', '=', $tagId); })->get() ...

Mailchimp returns true but email not in list of subscribers

php,laravel-4,mailchimp

I'm not super familiar with the laravel library, but typically this happens when you forget to set double-opt-in to false. [email protected] likely got sent a double opt-in confirmation message.

Issue when trying to populate a drop-down with database values

mysql,laravel,laravel-4,eloquent

Have a look at the Forms & HTML helper of laravel. Generating A Drop-Down List With Selected Default echo Form::select('size', array('L' => 'Large', 'S' => 'Small'), 'S'); where the first argument is the name of the select box. The second argument is an array of all entries in the box...

2 Foreach Loop Inside A Table

php,loops,laravel-4,foreach,blade

You create new TD for each member. The nested foreach has to be: <td> @foreach($user as $mem) {{ $mem->name }}<br> @endforeach </td> The result will be: <td> Name 1<br> Name 2<br> Name 3<br> </td> I don't know the template engine you used, add inside a loop condition and don't put...

Updating a pivot table

laravel,laravel-4,eloquent,laravel-5

You can add a boolean to your sync method which just adds the value and doesn't remove the existing value. The code looks like this. The first value can be an int or array. Product::find(1)->user()->sync([1], false); ...

how to add custom dynamic text footer in laravel 4.2 using dompdf

laravel-4,dompdf

The solution from the link you provided should be enough. You just need to craft a more complete HTML document. $html = <<<EOT <html> <head> <style> @page { margin-bottom: 50px; } .footer { position: fixed; bottom: -50px; margin: 10px; } </style> </head> <body> <h1>naeem World!!</h1> <h2>section 1</h2> <div style="page-break-before: always;"></div>...

JavaScript click function table cell only applied on the first row

javascript,jquery,laravel-4,blade

ID of an element must be unique, since you are creating the elements in a loop use class. When using ID selector it will return only the first element with the said ID, so in your case the click handler is getting registered to only the first element <tbody> <?php...

Should I make that re-set password link expire at a certain period of time? [closed]

php,laravel,laravel-4,laravel-5,reset-password

If you are using laravel 5, this option comes as a boiler plate. all you have to do is migrate the users and password_reset tables. The token is automaticaly expired in 60 minutes.

Boostrap thumbnail slider load dynamic conent

php,jquery,twitter-bootstrap,laravel-4

<div class="productslider carousel slide data-slider" id="prod158"> <div class="carousel-inner"> @foreach(array_chunk($products,5) as $row) <div class="item active"> <ul> @foreach($row as $product) <li class="product col-sm-2"> <a href="#" alt=""> <img src="#" width="160" height="120" alt="loading"> <span>Title</span> </a> <span class="text">Price</span> </li> @endforeach </ul> </div> @endforeach <a data-slide="prev" href="#prod158" class="left...

SubQueries in Laravel 4.2

mysql,laravel-4,eloquent

If you have two tables...I have one solution for your question.. you dont need use joins for this. Table1 name 'truckgps' and table 2 name 'truckgpss' My Ans $truckgps = DB::table('truckgps')->select('Truck_Number','Created','Latitude','Longitude','Speed','Heading ')->get(); foreach ($truckgps as $t) { $result = DB::table('truckgpss')->select('MAX(Created_dt) AS MaxDate ','Truck_Number')->where('MaxDate','=',$t->Created_dt )->where('Truck_Number','=',$t->Truck_Number)->groupBy('Truck_Number') ->get(); // if u need...

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...

What difference index.php vs index.blade.php in laravel?

laravel-4,blade

They're both php scripts. However, the Laravel Templates documentation page states that all Blade templates should use the .blade.php extension. If you rename the script to just .php your templates will not work as expected and will only output the contents of the script and execute any php code in...

WhereNotIn In Laravel 4

php,laravel,laravel-4

I Solved It just by using toArray() as bellow $Check = SubjectSchedule::whereNotIn('id', $studAttend->toArray()); Now not return [] ...

Laravel 4 Internal Server Error 500 and TokenMismatchException in a HTML Table to update the database with ajax

php,jquery,ajax,laravel,laravel-4

You may add a token in your HTML as a hidden field like <input type="hidden" id="token" value="{{csrf_token()}} > And then pass it to your ajax post request as _token ...

Issues on routes and blade with dynamic variable

php,laravel-4

First of all, you should pass the $slug variable to your view like this: <?php Route::get('/{slug}', function($slug) { return View::make('page', array('slug' => $slug)); }); And, in your blade view... Don't use single quotes when you're using variables. @include("modules.page.$slug") ...

Laravel - Auth error on page

laravel-4

You are using blade template engine, why do you use php thags then? If you want to display values, you can just do this: @if (Auth::check()) Hey,{{ Auth::user()->username }} if you see this, than you have been logged in! <a href="{{ URL::to('logout') }}">Logout</a> @else You have to be logged in!...

Laravel - Colums updates after logout

laravel-4

The function Auth::logout(); does refresh all that data. Otherwise you can try to add this code in your class: public static $timestamps = false; ...

Multiple Where In

mysql,laravel,laravel-4,eloquent,laravel-5

This is very interesting question. 0 = 1 will always be false, so your query will return zero rows. But why is this? Because by setting ->whereIn('size', $size) Laravel assumes that you always want the returned rows to be with one of the sizes in the passed array. If you...

Laravel Undefined index Error in array values display

php,mysql,laravel-4

As a rule of thumb, use var_dump to debug and see how your arrays look like at different places within your code. For example you can see what does $res look like inside the foreach loop in the view and see why you have any undefined indices. Overall your code...

retrieving multiple records associated to multiple records laravel 4.2

php,laravel,laravel-4,eloquent,blade

You should use Eloquent's relationships to solve this problem. See more here: http://laravel.com/docs/4.2/eloquent#relationships The way I see it currently is that you have three models that you're working with: Quiz, Question and Answer - right? From your question I gather the following: A Quiz will have many Questions An Answer...

Set base path in laravel 4

laravel-4

If you want to specify the controller and method in the Form open function you have to use action, not post as you have put in your question. Form::open(array('action' => '[email protected]')) Hope that helps solve the issue....

How to write a migrate to undo the unique constraint in Laravel?

php,laravel,laravel-4,laravel-5,database-migration

You have to do $table->dropUnique('users_email_unique'); To drop an index you must specify the index's name. Laravel assigns a reasonable name to the indexes by default. Simply concatenate the table name, the names of the column in the index, and the index type. ...

how to save pdf in directory laravel 4.2 using dompdf

php,laravel-4,dompdf

Dompdf's stream() method always sends to the browser. If you want to capture the output and save to a file you should use the output() method instead. $pdf = \App::make('dompdf'); $pdf->loadHTML('<h1>Hello World!!</h1>'); file_put_contents("order_email.pdf", $pdf->output()); ...

Laravel orderBy on with

php,laravel,laravel-4,eloquent,laravel-5

try this Menu::where('slug', 'main-navigation')->with([ 'MenuItems' => function($query) { $query->orderBy('MenuItems.sort_order', 'asc') } ])->get(); This will sort all the menu-items under each menu as per sort_order....

I can't use some Eloquent methods

laravel-4,eloquent,cartalyst-sentry

While I was waiting for an answer ;), I still having problems with Eloquent methods. I cant use something as $user->books()->get() or ->attach() in a relation many to many users and books, also with User::with('books') I have the same problem Call to undefined method Illuminate\Database\Query\Builder::xxxx() My problem is becouse of...

Laravel Call to undefined function [closed]

php,laravel-4

You need to read up on how Classes work. To access a function within a class you need to use the $this keyword. In your instance $users = $this->Test(0);

Routing issue with Laravel 4 and AngularJS in html5Mode

angularjs,laravel-4,angularjs-routing

I found a solution in this question and changed missing routes catching in Laravel to this one and everything is fine. App::missing(function ($exception) { return Redirect::to('/#/' . Request::path()); }); The problems were Angular in html5Mode need # as a prefix. Laravel was returning main page in subroutes including assets as...

Laravel 4 - Scope to only show rows where another DB has no relational items

laravel-4,eloquent,pivot-table

Assuming the car_image consists of the images of the cars: In your Car model: public function images() { return $this->hasMany('CarImage'); } In your CarImage model: public function car() { return $this->belongsTo('Car'); } Now you can load the cars without images like so: return Car::doesntHave('images')->get(); Using: doesntHave....

Carbon - get first day of month

php,datetime,laravel-4,php-carbon

Try as $start = new Carbon('first day of this month') CARBON DOCS Refer #Testing Aids...

How can I move file in php Laravel 5 ?

php,laravel,laravel-4,laravel-5

You're moving the file in the wrong direction. It should be $move = File::move($old_path, $new_path); ... in other words, the first argument should be the OLD file location, the second argument should be the NEW file location... you have it backwards. :) From the Laravel Docs Move A File To...

Route [[email protected]] not defined error in Laravel4

php,laravel-4,forgot-password

Welp, if you look at your form you have action="{{action('[email protected]')}}" But according to you, the only route you added was [email protected] I'm assuming you want just the get to quickly check the view right now, but maybe the action() is actually eagerly looking for that non-existent route. Is your app...

Laravel 4.1, White Blank Screen When using Eloquent

php,laravel-4

When you define sections you can tell blade how and when to display them, you do that with the closing directives like @stop, @show, @overwrite etc. @stop means you define a section for later use(meaning it doesn't show) so it can be used or be overriden later by another. To...

implementing ckeditor in laraval 5

laravel,laravel-4,laravel-5

You shouldn't need a bundle to use CKEditor - you can download the whole package of js files from the ckeditor website. Once you have it, place the folder containing all the downloaded files inside of your js folder In your view you can now reference the ckeditor.js file: {{...

Laravel 5 - Add a stylesheet only if on a certain page/controller

laravel,laravel-4,laravel-5,blade

You may create a section like the following in your view, for example: @extends('layouts.master') @section('styles') <link href="{{asset('assets/css/custom-style.css')}}" /> @stop Then also in your layout, @yield that, for example: <!--Static StyleSheets--> <link href="{{asset('assets/css/common-style.css')}}" /> <!--Dynamic StyleSheets added from a view would be pasted here--> @yield('styles') Same goes for script tags, for...

why session push in laravel store my value in new array with zero index

php,laravel-4

You could simply use Session::put('step_1.security', 'yes')); $vat=10; Session::put('step_1.vat', $vat); ...

Laravel logs don't write when queued by beanstalkd daemon

laravel-4,beanstalkd

This was caused by the fact that when run as a daemon the app instance stays in memory perpetually, so any code changes (such as introducing log lines) won't be reflected. To fix this, execute php artisan queue:restart or simply click the restart icon in Forge (if using that) after...

fgets() halting without error in Swiftmailer

php,laravel-4,fgets,swiftmailer

Ok, progress: after broadening my search to Swiftmailer in general, I was able to find mention of a timeout occurring at that particular line in Swiftmailer. By extending the max_execution_time in php.ini I was able to get an actual Exception: Expected response code 220 but got code "", with message...

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 '); }); ...

Login fail in laravel 4.2

php,laravel,laravel-4,basic-authentication

$user = array( 'username' => Input::get('username'), 'password' => Input::get('password') ); You must remove Hash::make() in Auth::attempt(), because Laravel makes hashing automatically (I suppose that you register user with Hash::make(Input::get('password'))). ...

Access a protected field from queried Eloquent object

php,laravel,laravel-4,eloquent

Turns out, if I use auto-incrementing IDs, I can access the id attribute of the newly created model, right after it has been created in the DB. So, this is the whole fix: $trip->save(); $trip_redirect_id = $trip->id; ...

Laravel 4 eloquent WHERE with AND and OR?

laravel-4,eloquent

for multiple where statements use: $result = Model::whereRaw('(a = ? and b=?) or (c=? and d=?)', ['x','y','z','j'])->get(); ...

How to recover destroyed laravel project with composer

php,json,laravel-4,composer-php,alerts

Your general problem is that you are using branches instead of versions. branches have two major problems: They don't point to a distinct code that was committed once in time, but are a moving target that constantly gets updates. They inherently are of development stability, which could be an acceptable...

How can i refactor my angular code for my laravel app so i have the controllers in separate files?

angularjs,laravel-4

You could create an extra module, like: angular.module('ReporterApp.Controllers', [ /* dependencies here */]) Then you can do .controller( ...etc...). Then inject this module in your 'main' module. That way you can have different files containing different controllers, all in the ReporterApp.Controllers module. A simple example: File 1: angular.module('ReporterApp.Controllers') .controller('myCtrl', ['$scope',...

Move and rename picture with Intervention/image module

php,laravel,laravel-4,image-uploading,intervention

Run simply php rename function rename("/public/temp/image1.png", "/public/my-folder/my-image.png"); php rename manual...

Querying one-to-one in laravel

php,laravel-4,orm,eloquent

Hi You can fetch this by this ways : Find Top 10 cities which have the maximum business: $city = City::with('business')->get()->sortBy(function($query) { return $query->business->count(); }, SORT_REGULAR, true) ->take(10); Find Business by city name. Business::whereHas('city', function ($q) { $q->where('name', 'like', 'search_string');//name is the city_name as per your attributes name })->get(); ...

foreign key not recognised in laravel 4.2

php,mysql,laravel,laravel-4

This was your problem. You have named your relation artists, but it should be artist. That's why it was looking for a column named artists_id. You should define your relations as follow as it looks to me it is a One to Many. In your Artists Model public function albums()...

Tinder Laravel matching between 2 models

php,laravel,laravel-4,eloquent,tinder

As I understand your question, in your application, a user can like an employer, and an employer can like a user. If this is right, it seems clear to me that there are two distinct (many to many) relationships (user => employer, employer => user), and that in your proposed...

Best way of protecting the show() method against users accessing other users messages

laravel,laravel-4,routing,models,relationships

in the simplest form, in your MessagesController in the show method, you can add an additional parameter to your query and get the record where message_id = the paramater from the url and the user_id on that message is the authenticated user's ID.... do something like $message = App\Message::where('id', '=',...

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...

Relationship results automatically coming out?

laravel,laravel-4,eloquent,laravel-5

Relationship results automatically coming out? No, basically when you do $data = Product::all(); foreach ($data as $value) { var_dump($value->title); } You are doing this: select * from products But then on your foreach, since you are trying to access a property that wasn't loaded, you are doing a new...

how to fix stream_socket_enable_crypto(): SSL operation failed with code 1

laravel-4,amazon-ec2,ssl-certificate,apache2.4,php-5.6

Try changing the app/config/email.php smtp to mail...

How to Display Blade Content stored in a Db row

laravel-4,blade

You can compile blade syntax string, stored in a DB row or a variable by extending Blade Compiler. Solution code taken from here, I have not tested the code myself. <?php namespace Laravel\Enhanced; use Illuminate\View\Compilers\BladeCompiler as LaraveBladeCompiler; class BladeCompiler extends LaraveBladeCompiler { /** * Compile blade template with passing arguments....

Laravel setup, trying to have cronjob call a function within php laravel file

php,laravel,laravel-4,cron,laravel-5

A very convenient way is to use laravels console component. You can create a new command by issuing php artisan make:console And find it thereafter in your app/console directory. Make sure to enable the command in the Kernel.php file once created. Simply call your class or whatever you want to...

foreach loop not working with laravel queue

php,laravel-4

The problem was with email_campaign_id to be null because $data['campaign_id'] was null the correct foreign key was $data['email_campaign_id'] that's what stopped the process - I should have tested it before putting it in the queue after changing the code EmailCampaignRecord::create([ 'email_campaign_id' => $data['campaign_id'], 'mandrill_email_id' => $response[0]->_id, 'status' => $response[0]->status, 'to_email'...

Can not access the 3rd table in laravel 5 in 3 tables have relationships

laravel,laravel-4,eloquent,laravel-5

You should use whereHas $groups = Group::whereHas('keyword', function($query) { $query->where('user_id' => Auth::user()->id); })->get(); ...

Laravel 4.2 : add soft deleted items to whereHas condition

laravel-4

One solution to this is creating an alternate form of the relationship that includes trashed records. public function dspsTrashed() { return $this->hasWhatever()->withTrashed(); } Then: $this->model->whereHas('dspsTrashed', ...); ...

orWhere giving unexpected result

laravel,laravel-4,eloquent,laravel-5

It is because you build your query to return all records that have this lang_id and title, OR description starting with some search keyword. And that's why you get another results, because some of them don't meet the lang_id requirement, but they meet the description match. You need to group...

Saving vs. submitting a form

html,laravel,laravel-4

You can have two submit buttons inside a form with different names and values: <button type="submit" name="action" value="save">Save</button> <button type="submit" name="action" value="submit">Submit</button> You can then check the value in your controller action: public function postSubmission() { if (Request::get('action') == 'save') { // Save form for later } elseif (Request::get('action') ==...

Call to undefined method Illuminate\Support\Facades\Log::save()

laravel,laravel-4

Yes the problem is indeed a conflict with the Log facade alias. To fix it use namespaces: <?php namespace YourApp; class Log extends Eloquent { public function user() { return $this->belongsTo('user'); } } And then you can use your class like so: $log = new YourApp\Log(); You could of course...

Difficulity with blade foreach

php,twitter-bootstrap,laravel-4,foreach

There are some problems in your code: First, your modal code should not be inside the tr element, put it out of the table or inside another td element. Second, each modal should have its unique id and the button of each row will use that modal id in data-target...

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

Do you have good reason to believe that scandir on a directory with a large number of folders will actually slow you down? You can do your query like this: if(Input::has('field')){ $filenames = scandir('img/folders'); $query = Model::whereIn('id', $filenames)->get(); } Edit 1 You may find these links useful: PHP: scandir() is...

Redirect is not working on Laravel 4

laravel,redirect,laravel-4,require

This answer assumes that plivio.php is from this git repo. The issue is that the plivo.php library defines a Redirect class in the global namespace. Because of this, Laravel does not register the global Redirect alias to point to the Illuminate\Support\Facades\Redirect facade. So, in your final line return Redirect::back()->with(...);, the...

Better way to get database info

php,mysql,laravel,laravel-4

Your model should look like this: class Seat extends Eloquent { protected $fillable = array('user_id','timestamp','temp_user_id','temp_timestamp', 'class', 'seat_id', 'seat_name'); protected $table = 'seats'; private $classes = array( "blank" => array( "css_class" => "seating_blank", "can_reserve" => 0, "show_title" => 0, "title" => "Blank" ), "available" => array( "css_class" => "seating_green", "can_reserve" =>...

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 ;....

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 ...

Eloquent sortBy - Specify asc or desc

php,arrays,laravel-4,eloquent

http://laravel.com/api/4.1/Illuminate/Database/Eloquent/Collection.html#method_sortBy $collection->sortBy('field', [], true);//true for descending...

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...

Using Input::all() when uploading files in laravel 4.2

php,laravel,laravel-4

If you see into /vendor/laravel/framework/src/Illuminate/Http/Request.php, /** * Get all of the input and files for the request. * * @return array */ public function all() { return array_replace_recursive($this->input(), $this->files->all()); } which contains both files and other inputs. Since CodeBright was started with laravel 3, ( http://goo.gl/NWltLh ), I suppose (but...

jquery events on advanced datatables

jquery,laravel-4,datatables

Use a delegated event handler : $('#table').on('click', '.pay-btn', function(e) { dataTables inject and remove table rows to the DOM in order to show pages. Thats why your event handler not is working except from page #1. NB: Dont know what your <table> id is - replace #table with your id....

Laravel get most out of the database

php,laravel-4,tracker

You can SELECT the date ORDER BY the amount of visitors DESCENDING and LIMIT by 1. This is basic mysql. How to use this in laravel, is in the documentation. Order by desc: ->orderBy('visits', 'desc') Limit: ->take(1) My example query is based on a system that has a column which...

Binding vars to raw queries

laravel,laravel-4,eloquent,laravel-5

you must bind variables to raw method not select: $select = "(3959 * acos(cos(radians(:lat)) * cos(radians(lat)) * cos(radians(lng) - radians(:lng)) + sin(radians(:lat)) * sin(radians(lat)))) as distance"; $data = $myModel->select( DB::raw($select,array( 'lat' => $lat, 'lng' => $lng, )))->orderBy('distance', 'ASC')->having('distance', '<', $radius) ->get(); Or use selectRaw method directly: $data = $myModel->selectRaw($select,array( 'lat'...

Combining multiple relation query in one - laravel

php,mysql,laravel,laravel-4,has-and-belongs-to-many

What you want is Eager Loading, this will reduce your query operations into two queries. Quoting the Laravel Eloquent docs, using your example: Your loop will execute 1 query to retrieve all of the Groups on the table, then another query for each group to retrieve the items. So, if...

Laravel 4 Input::old() not working

laravel-4

You need to pass over the data into the View: return View::make('ajax.view') ->withInput(Input::all()) ->withErrors($validation) ->render(); ...