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...
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....
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...
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...
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...
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....
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...
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);
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...
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()); ...
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...
http://laravel.com/api/4.1/Illuminate/Database/Eloquent/Collection.html#method_sortBy $collection->sortBy('field', [], true);//true for descending...
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>...
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...
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...
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'))). ...
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...
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; ...
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...
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...
laravel,laravel-4,laravel-5,laravel-validation
In Laravel 5 you have something similar, which handles better the validation and makes validation clean and easy. It is called Form Request Validation. The idea there is the same - to have different classes that handle validation in different scenarios. So whenever you need a validation you can create...
I Solved It just by using toArray() as bellow $Check = SubjectSchedule::whereNotIn('id', $studAttend->toArray()); Now not return [] ...
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...
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...
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',...
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...
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...
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()...
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.
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...
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...
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...
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', ...); ...
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...
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...
php,datetime,laravel-4,php-carbon
Try as $start = new Carbon('first day of this month') CARBON DOCS Refer #Testing Aids...
Your issue: public function foo() { dd($this->$date); } needs to be public function foo() { dd($this->date); } ...
$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+...
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...
Try as below : <?php $properties = array('office', 'retail'); ?> @foreach ($properties as $property) {{{ $property }}} @endforeach ...
You could simply use Session::put('step_1.security', 'yes')); $vat=10; Session::put('step_1.vat', $vat); ...
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....
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,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...
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...
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...
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...
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...
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.
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!...
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(); ...
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'...
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') ); ...
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',...
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,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...
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....
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-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,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> ...
laravel-4,amazon-ec2,ssl-certificate,apache2.4,php-5.6
Try changing the app/config/email.php smtp to mail...
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'...
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 ...
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...
php,mysql,laravel-4,query-builder
Did you tried using raw ? Org::select(DB::raw('name as `Organization Name`, status'))->where('id',$user->orgId); ...
The function Auth::logout(); does refresh all that data. Otherwise you can try to add this code in your class: public static $timestamps = false; ...
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...
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...
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') ==...
You need to pass over the data into the View: return View::make('ajax.view') ->withInput(Input::all()) ->withErrors($validation) ->render(); ...
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....
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...
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...
for multiple where statements use: $result = Model::whereRaw('(a = ? and b=?) or (c=? and d=?)', ['x','y','z','j'])->get(); ...
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...
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...
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...
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. ...
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,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...
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 '); }); ...
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...
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...
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,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...
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....
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" =>...
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', '=',...
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); ...
As your class is not namespaced - try and call it like this: $auth_id = "Your AUTH_ID"; $auth_token = "Your AUTH_TOKEN"; $p = new \RestAPI($auth_id, $auth_token); Notice the \ before RestAPI...
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...
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...