FAQ Database Discussion Community


Matched data inside select supposed to selected by default

laravel,if-statement,laravel-4,foreach,blade
I have a database that contains project_development and developer. I want to make an edit form for the project_development that has select with option from developer table. when the data matches, the current option will be selected. It works fine on other select without the foreach loop statement. <select class="form-control"...

Difficulity with blade foreach

php,twitter-bootstrap,laravel-4,foreach
I am using Laravel 4.2 and I'm stuck in using a blade foreach loop to create a table. The table shows some records and when the user clicks on the details button, a bootstrap modal opens for that record. Unfortunately the opened modal just shows the details for the first...

Better way to get database info

php,mysql,laravel,laravel-4
Alright, so I have this seating system, that generates a 30x30 grid, and for each grid, there is an row in the database, but when I generate this grid on my page, I currently make 5 SQL request per element (and there is 900 elements), which we all know is...

Id Column Overwritten by Join

php,mysql,laravel,laravel-4,eloquent
Using Laravel 4.2 & MySQL. I have an applications table with an id and a fit_score_id column, and a fit_scores table with an id column. It's a basic "belongs to" relationship. The following code: $query = Application::join('fit_scores', 'applications.fit_score_id', '=', 'fit_scores.id'); $collection = $query->get(); ...produces a collection of Application models with...

Laravel logs don't write when queued by beanstalkd daemon

laravel-4,beanstalkd
If I fire the queue from the command line, my log lines write to the log along with any errors. However, if the queue fires from the beanstalkd queue run as a daemon then no errors or explicit Log calls are written. What could be blocking them when queued?...

Laravel Call to undefined function [closed]

php,laravel-4
i'm wondering why laravel dont find simple function into controller. for example this is my simple function into Controller class Accounts Controller extends \BaseController { public function Test($id) { return DB::table('accounts')->where('user_id', $id)->get(); } public function getIndex() { ...... $users = Test(0); } public function postUpdate() { ........ } } Error:...

How to recover destroyed laravel project with composer

php,json,laravel-4,composer-php,alerts
I am using laravel 4.2. Today I had to reinstall one of my plugins, and now all my project has been destroyed. here's my composer.json file : { "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "type": "project", "require": { "laravel/framework": "4.2.*", "barryvdh/laravel-debugbar": "~1.8", "mews/captcha": "dev-master", "prologue/alerts":...

I can't use some Eloquent methods

laravel-4,eloquent,cartalyst-sentry
I'm trying to use Eloquent with a relationship and alwys have th same result: Call to undefined method Illuminate\Database\Query\Builder::xxxx() where xxxx could be "sons" defined in my model or save() if I use another code. First of all I have this two models (simplified): <?php use Cartalyst\Sentry\Users\Eloquent\User as SentryUserModel; class...

Redirect is not working on Laravel 4

laravel,redirect,laravel-4,require
In my controller function I am using a require statement to include a file, like, require app_path().'/plivo/plivo.php'; After this statement, when I try to redirect from this controller using the statement, return Redirect::back()->with('success', 'Note added successfully'); It gives me an error Call to undefined method Redirect::back() How can I redirect...

How can I move file in php Laravel 5 ?

php,laravel,laravel-4,laravel-5
I'm trying to move file from one place to another place. In this case is my user profile picture. Since I store my user profile picture base on their username, so when they change their username. I will need to move thier profile photo, Otherwise, the image link will be...

How does laravel relate an actual table to the eloquent class?

laravel,laravel-4,laravel-5
How does laravel relate an actual table to the eloquent class ? From what i understood is that the class name should be same as the table name but without the s example Articles table the Eloquent class name is Article. But what if the table name is Article or...

how to call a class function of an included php file Laravel 4

object,laravel-4,plivo
I have a php file plivo.php in app/plivo folder. This included in my controller like, require app_path().'/plivo/plivo.php'; The plivo.php contains a class, RestAPI . When I try to create an object like, $auth_id = "Your AUTH_ID"; $auth_token = "Your AUTH_TOKEN"; $p = new RestAPI($auth_id, $auth_token); Produce an error: Class 'Controllers\Account\RestAPI'...

Laravel 4 Input::old() not working

laravel-4
{"error":{"type":"ErrorException","message":"Undefined offset: 0" MyController.php Input::old() is empty. How to store some data in the input old? sorry for my english =D return View::make('ajax.view') ->withInput() ->withErrors($validation) ->render(); ...

Combining multiple relation query in one - laravel

php,mysql,laravel,laravel-4,has-and-belongs-to-many
I have 2 tables :- items and groups groups table as below :- create table groups (`id` int unsigned not null auto_increment, `group_name` varchar(255), primary key(`id`) ); items table as follows :- create table items (`id` int unsigned not null auto_increment, `group_for` int unsigned not null, `item_name` varchar(255), primary key(`id`),...

implementing ckeditor in laraval 5

laravel,laravel-4,laravel-5
I want to implement ckeditor in laraval 5. I have already installed IvoryCKEditorBundle. but for implementation the docs says to register a new form field type called ckeditor that extends the textarea. How should i do that ?...

retrieving multiple records associated to multiple records laravel 4.2

php,laravel,laravel-4,eloquent,blade
recently i asked this question which got one answer but unfortunately didn't solve the problem, after that i got no more answers and i really need to fix this problem i have. Alright so i have to make a quiz website for my school in which a user should be...

Laravel 4 to Microsoft SQL server remote

sql-server-2008,ubuntu,laravel-4,ubuntu-12.04
I'm trying to connect Laravel (Server: Ubuntu 12.04 x64) to remote Microsoft SQL server 2008 R2. I'm using sqlsrv. 'sqlsrv' => array( 'driver' => 'sqlsrv', 'host' => 'localhost', 'database' => 'test', 'username' => 'sa', 'password' => 'pass', 'prefix' => '', ), how can I do it?...

Wordpress blog + Laravel with SEO friendly urls

php,wordpress,apache,.htaccess,laravel-4
I have a website with Laravel, I am starting a wordpress blog on the website with url. http://abcd.com/blog I have uploaded wordpress blog in the public directory of laravel. To exclude wordpress blog from laravel htaccess rules, I have added following line in my laravel htaccess RewriteCond $1 !^(blog) It...

Stripe billing class not found - Laravel

php,laravel-4,stripe-payments
I have added the Stripe library to my composer.json file, ran all commands just to check... update, dump-autoload etc. In my classmap file the library is shown: 'Stripe\\Account' => $vendorDir . '/stripe/stripe-php/lib/Account.php', and so on... In my app folder i have my classes folder etc: app motivate Billing BillingInterface.php StripeBilling.php...

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

php,laravel-4,forgot-password
I was implementing Laravel's password reminded function but hitting this error: Route [[email protected]] not defined. I am using Laravel 4 and absolutely new to Laravel.I used php artisan auth:reminders-controller to create RemindersController. <?php class RemindersController extends Controller { public function getRemind() { return View::make('password_remind'); } public function postRemind() { Password::remind(Input::only('email'),...

Laravel Blade: Increment variable by 1 each time?

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

Laravel 4 eloquent WHERE with AND and OR?

laravel-4,eloquent
How do I say WHERE (a=x AND b=y) OR (c=z AND d=j) For x , y , z .. are variables . How can i do that with eloquent ?...

orWhere giving unexpected result

laravel,laravel-4,eloquent,laravel-5
I want to search pages whose lang_id = 1, I am using following laravel query $result = $this->where('lang_id', $this->langId ); $result->where('title', 'LIKE', '%'.$search.'%') ->orWhere('description', 'LIKE', '%'.$search.'%'); $result->get(); It gives me pages having lang_id other than 1 too. How to fix it?...

Querying a Pivot table in Laravel 4

mysql,laravel,laravel-4,model,relationship
I have a Email model with the table 'messages' that contains all the message data. I also have a pivot table 'message_users'. How could I return all the messages that a user is associated with? ...

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

php,laravel,laravel-4,cron,laravel-5
Original Post Good evening folks. I have a laravel setup and I'm trying to have a cronjob execute a php function to a file within the laravel project directory. I am getting class and name space errors when I try to do something like this: <?php require_once('../laravel/app/Http/Controllers/NotificationsController.php'); and then calling...

2 Foreach Loop Inside A Table

php,loops,laravel-4,foreach,blade
I had Users table and group table, when i load a group table, it loads the user which have same group_id as the group table id. it works, but my problem is the foreach was quite a mess. the output looks like this.. however, i want to make the output...

Error in laravel 4

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

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

laravel,laravel-4,eloquent,laravel-5
I have these table - users table id name password - keywords table id name user_id - groups table id name keyword_id I want to retrieve logged in user groups $groups = Group::with(['keyword' => function($query){ $query->where('user_id' , Auth::user()->id) }]); but all groups return NOT that groups for that user....

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

php,laravel,laravel-4,laravel-5,reset-password
Form When my user is forgetting their password, I asked them for an email so I can send them the re-set password link. Right now I embeded the link into the btn, that link doesn't have any expiration time on it. But if they re-submit an email again, the I...

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

php,jquery,ajax,laravel,laravel-4
I have a table where I show basic information. It's basically a two-column table with n rows. In the second column I show a select tag where the user should choose an option (in this case, a country). The corresponding value of the chosen option will be updated in the...

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
I am using laravel 4.2 I have a login form where I am trying to implement the remember me functionality. I have used Auth::attempt() to implement the above. Here's my code. public function logintest() { // set the remember me cookie if the user check the box $remember = (Input::has('remember'))...

WhereNotIn In Laravel 4

php,laravel,laravel-4
I have issue with whereNotIn in laravel 4 , i need to get that not in from array of ids as bellow $studAttend = StudentAttendees::select('subject_schedule_id')->distinct()->get(); $Check = SubjectSchedule::whereNotIn('id', array($studAttend))->get(); Also I tried to change my code to loop over $studAttend as bellow $studAttendArray = array(); foreach ($studAttend as $stdAtt) {...

run laravel downloaded project on local machine

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

SubQueries in Laravel 4.2

mysql,laravel-4,eloquent
Can anyone teach me how can we use a query like this in Laravel 4.2 SELECT t.Truck_Number, t.Created_dt, t.Latitude, t.Longitude, t.Speed, t.Heading FROM truckgps t INNER JOIN ( SELECT Truck_Number, max(Created_dt) as MaxDate FROM truckgps GROUP BY Truck_Number ) tm ON t.Truck_Number = tm.Truck_Number AND t.Created_dt = tm.MaxDate this query...

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

php,laravel,laravel-4,laravel-5,database-migration
I would do this to make my email field unique in the table. $table->unique('email'); I've tried public function up() { Schema::table('contacts', function(Blueprint $table) { $table->dropUnique('email'); }); } Then, when I run php artisan migrate, I got this It tell me that it's not there, but I'm 100% sure that it's...

Trying to figure out a how call works in twilio

php,laravel-4,twilio,twilio-php,twilio-click-to-call
As subject says I am reading api docs for twilio but even after brainstorming for 2 hours I am still unable to figure out exactly how can I receive a call from twilio on my web application and answer the call with my own voice like we do in a...

Updating a pivot table

laravel,laravel-4,eloquent,laravel-5
I have a pivot table id | product_id | user_id I wish to update this pivot table, I do so by: Product::find($productId)->attach($userId); This will produce something like id | product_id | user_id 1 1 1 But then when I do it again I do not want to update the pivot...

Node.js with Laravel 4.2

php,node.js,amazon-web-services,laravel-4,ratchet
I currently working on php project - Laravel 4.2 framework. I need to use node.js. Need to real time update count of users that registered, on dashbord. I tried with Ratchet , but I'm not clear following file path that we must edit. /src/MyApp/Chat.php /bin/chat-server.php Does someone have experience working...

fgets() halting without error in Swiftmailer

php,laravel-4,fgets,swiftmailer
I'm attempting to generate a test email in Laravel 4.2 (Windows 7, IIS 6.1), and I've encountered a silent termination - it just fails, doesn't return my view, and doesn't return an error or Exception. I've managed to brute force my way through the Laravel codebase and located the termination...

Laravel 5 form request validation returning forbidden error

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

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

laravel-4,dompdf
i have followed this example laravel-4-create-pdf-use-dompdf: how to add custom dynamic footer $dompdf = \App::make('dompdf'); $dompdf->loadHTML('<h1>naeem World!!</h1>'); anyone do have idea? or please suggest, i also have followed this solution DOMPDF add a header and footer but it doesn't work correctly. Edited: i want $db_data['footer_text'] to be footer text to...

Move and rename picture with Intervention/image module

php,laravel,laravel-4,image-uploading,intervention
I'm using 'Intervention/image' module , have two folders , i want to move and rename image . public/temp/image1.png to public/my-folder/my-image.png...

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

php,mysql,laravel-4,eloquent
Business Modal class Business extends \Eloquent implements UserInterface, RemindableInterface{ public function services() { return $this->hasMany('Services'); } } Service Modal class Service extends \Eloquent { public function business() { return $this->belongsTo('Business'); } public function tag() { return $this->belongsToMany('Tag','service_tags','service_id','tag_id'); } } Tag Modal class Tag extends \Eloquent { public function service() {...

Larevel/SQL: Query model where relationship = X

php,sql,laravel-4,eloquent
Context I have three models below: listing, rooms and room types - LISTING |-----|-------------|--------------------| | ID | title | description | |-----|-------------|--------------------| | 1 | some title | some description | | 2 | some title | some description | | 3 | some title | some description | etc...

Multiple Where In

mysql,laravel,laravel-4,eloquent,laravel-5
I'm using eloqent to filter a set of products: Product::whereIn('color', $color)->whereIn('size', $size)->whereIn('price', $price)->get(); Each of the above variables is an array of ids $color = [1,2,4,5] My question is, is this inefficient when the user fails to send through a set of variables, say they did not want any color...

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

angularjs,laravel-4
I would like to have the code as structured as possible and right now all my controllers and routes are kept in the same file. I am using laravel 4.2 for the back end and templating and angular for the front end part of the app. This is how the...

Carbon - get first day of month

php,datetime,laravel-4,php-carbon
I am using carbon but trying to get the first day of the month so I can run a report from the beginning of the month till the current day. $date = [ 'start' => new \Carbon\Carbon('last month'), 'end' => new \Carbon\Carbon('today') ]; The above code will show todays date...

Proper use of Array and Foreach at Laravel

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

How to Display Blade Content stored in a Db row

laravel-4,blade
How can I Effectively Display Blade code stored in a DB instead of being displayed as a line of code? here is the image Inspecting the html I see " {{HTML::ul(array('a', 'b', 'c'))}} " If I can get rid of the quotes the blade content will be displayed...

Laravel - Colums updates after logout

laravel-4
I've created a login and logout. But When I want to logout, he updates my Created_at, updated_at and remember_token colum's Logout: public function logout() { Auth::logout(); // logout user return Redirect::to('login'); //redirect back to login } How can i fix that he not update my created_at colum?...

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

laravel-4,blade
The file can have any of those two extensions: .php or .blade.php? true or false?

Laravel - Auth error on page

laravel-4
If i want to test my Auth page, i get this error: Trying to get property of non-object (View: C:\xampp\htdocs\system\app\views\home.blade.php) And this is on my home.blade.php page: <?php $username = Auth::user()->username; $id = Auth::id(); if (Auth::check()) { ?> Hey, if you see this, than you have been logged in! <a...

Issues on routes and blade with dynamic variable

php,laravel-4
i have this Route code Route::get('/{slug}', function($slug) { return View::make('page'); }); ...let say, my url $slug is "about" as the value, inside my page.blade.php will need to see this $slug "about" and output it as @include('modules.page.$slug') where the $slug should be the about in short, i would like to happen...

Laravel 4.2 Sending email error

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

Laravel 4.2 : add soft deleted items to whereHas condition

laravel-4
I have an issue on Laravel 4.2 and found no solution on my Google friend : I want to get all soft deleted items in a whereHas condition and it doesn't work at all... Here is the code : $res = $this->model->whereHas('dsps', function ($q) use ($dsp_id) { $q->where('dsps.id', $dsp_id); $q->withTrashed();...

how to save pdf in directory laravel 4.2 using dompdf

php,laravel-4,dompdf
i have followed this example laravel-4-create-pdf-use-dompdf: i want to save pdf in directory not pdf preview in the browser. My current code: $pdf = \App::make('dompdf'); $pdf->loadHTML('<h1>Hello World!!</h1>'); return $pdf->stream("order_email.pdf"); but what this code is doing, it shows my "Hello World" text as PDF in the browser but not saving "order_email.pdf"...

Laravel routes matching everything after prefix

laravel,laravel-4,laravel-5,laravel-routing
I'm trying to match a path in a URL something like the following My HTTP Request http://localhost/myprefix/extra/x/x/x/x/x/2/3/2/ routes.php Route::group( ['prefix' => 'myprefix'], function () { Route::get('extra/{path}', ['as' => 'myprefix.one', 'uses' => '[email protected]']); Route::get('extraOTher/{path}', ['as' => 'myprefix.two', 'uses' => '[email protected]']); } ); MyController.php public function index($path) { // $path should be...

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

laravel,laravel-4
I created 'Log' class in app/models : class Log extends Eloquent { public function user() { return $this->belongsTo('user'); } } When i try to save log object in my controller i got this error (Call to undefined method Illuminate\Support\Facades\Log::save() ) I thik because in (app/config/app) in providers laravel define Log...

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

laravel,laravel-4,laravel-5,blade
My Laravel layout is currently as follows (removed navbar etc..): <link href="//maxcdn.bootstrapcdn.com/bootswatch/3.3.4/flatly/bootstrap.min.css" rel="stylesheet"> <link href="{{ asset('/css/app.css') }}" rel="stylesheet"> <!-- Fonts --> <link href='//fonts.googleapis.com/css?family=Roboto:400,300' rel='stylesheet' type='text/css'> <!-- Scripts --> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <!-- HTML5 shim and Respond.js for IE8 support of HTML5...

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

mysql,laravel,laravel-4,eloquent
I am using the following HTML to show a selected drop down with values from the database and rest of the others in the list. It shows the selected name correctly but the selected is also displayed in the list. How to remove the second time show selected name in...

Querying one-to-one in laravel

php,laravel-4,orm,eloquent
I have two models city and business.I have to perform below queries Find Business by city name. Find Top 10 cities which have the maximum business. Here is the models Business class Business extends \Eloquent { protected $fillable = [ 'business_type', 'first_name', 'last_name', 'email', 'password', 'designation_id', 'name', 'description', 'portfolio_id', 'image',...

Laravel 4.1, White Blank Screen When using Eloquent

php,laravel-4
I'm newbie in using Laravel & need the help. Why the white blank white screen appears in my web browser when i want using eloquent. The code in the below(Sorry for long post, i want make that clear): UserController.php(Controller) <?php class UserController extends \BaseController { /** * Display a listing...

count() “where” statement in Laravel blade?

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

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

laravel-4,amazon-ec2,ssl-certificate,apache2.4,php-5.6
stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed Im using Laravel 4.2 PHP 5.6 Apache 2.4 I have GoDaddy SSL installed in Amazon ec2 Linux. SSL working fine when i visit the site with https. The error happened when I call my function :...

foreign key not recognised in laravel 4.2

php,mysql,laravel,laravel-4
According to Dayle Rees All foreign key columns follow a similar naming convention. The singular form of the related model appended with _id. Consider this migration: class CreateTables extends Migration { // ... public function up() { Schema::create('artists', function($table) { $table->increments('id'); $table->string('name',64); $table->timestamps(); }); Schema::create('albums', function($table) { $table->increments('id'); $table->string('name',64); $table->integer('artist_id')->unsigned();...

Laravel Undefined index Error in array values display

php,mysql,laravel-4
I am using Laravel 4.2. I have two mysql tables OwnTable, OtherTable. I am getting values successfully from these tables through php. My further PHP code look like below to display values in blade php, if (!empty ($OwnTable)){ foreach($OwnTable as $owntbl){ $Finalvalue['OwnValue']['Name'] = $owntbl->Name; } } if (!empty ($OtherTable)){ foreach($OtherTable...

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

laravel,laravel-4,routing,models,relationships
Ok, so I have a basic messaging system, I have a relationship set up so I can just call $user->messages to retrieve an array of the users inbox messages. I also have a very simple show method that currently only grabs the message with id passed to the show() function....

Laravel get most out of the database

php,laravel-4,tracker
I'm having a tracker in Laravel 4 and I was wondering, how can I get the 'most' from my table. So want I want is to have the day that had the most visitors. My table structure looks like this: So, my controller looks like this: public function index() {...

Login fail in laravel 4.2

php,laravel,laravel-4,basic-authentication
I'm Laravel Beginner I make some web application using laravel 4.2 then I make login page but when I try to login it's go to login fail condition every time anyone tell why here is my code public function doLogIn(){ $rules = array( 'username' => 'required|min:3', 'password' => 'required|min:3' );...

foreach loop not working with laravel queue

php,laravel-4
I am using sync (local driver) for pushing up a queue in a update method of EmailCampaignController, which uses another method of the same controller named emailQueue like this Queue::push('[email protected]', array('campaign_id' => $campaign_id)); The emailQueue uses a foreach loop which runs correctly for once after that it gives error as...

Permission denied error on CSV export Laravel

csv,laravel,laravel-4,permission-denied
I am using Laravel 4. When I try to export a database table to CSV file I get this error, fopen(file.csv): failed to open stream: Permission denied This is my code, public function getExport(){ $table = Users::all(); $filename = "file.csv"; $handle = fopen($filename, 'w+'); fputcsv($handle, array('name', 'status')); foreach($table as $row)...

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

laravel-4
Here is my controller method: Contact::create([ 'name' => Input::get('name'), 'email' => Input::get('email'), 'confirmation_code' => $confirmation_code ]); Mail::send('blank', array('msg' =>'Welcome {{$name}}','name'=>Input::get('name'),'confirmation_code' => $confirmation_code), function($message){ $message->to(Input::get('email'), Input::get('name'))->subject(' '); }); Here is the Blank view: <!DOCTYPE html> <html lang="en-US"> <head> <meta charset="utf-8"> </head> <body>...

Routing issue with Laravel 4 and AngularJS in html5Mode

angularjs,laravel-4,angularjs-routing
I am creating a RESTful application with Laravel 4 as backend and AngularJS as frontend. I want to use routing from Angular. routes.php in laravel are set up like this (with one group /api, but it is not necessary) Route::any('{all}', function ($uri) { return View::make('index'); })->where('all', '.*'); My routes in...

Laravel relation many to many with additional pivot

php,laravel,laravel-4
Status Update I have implemented morph to many relationship type but how can I insert into the addition field? The code for the polymorphic relation is: public function mailmessages() { return $this->morphToMany('Mailmessage','rel','mailmessage_rels','rel_id','mailmessage_rel_id') ->withPivot(['addition']); } Original Post I have a Laravel project that uses many to many relations and in the...

Binding vars to raw queries

laravel,laravel-4,eloquent,laravel-5
I'm trying to bind vars to my raw query: $data = $myModel->select( DB::raw('(3959 * acos(cos(radians(:lat)) * cos(radians(lat)) * cos(radians(lng) - radians(:lng)) + sin(radians(:lat)) * sin(radians(lat)))) as distance'), array( 'lat' => $lat, 'lng' => $lng, ))->orderBy('distance', 'ASC')->having('distance', '<', $radius) ->get(); I've checked various SO posts which lead to this blog post:...

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails error in Laravel 4

mysql,laravel,laravel-4,foreign-keys,eloquent
I am recieving the following error: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`database`.`messages`, CONSTRAINT `messages_sender_id_foreign` FOREIGN KEY (`sender_id`) REFERENCES `users` (`id`) ON UPDATE CASCADE) (SQL: insert into `messages` (`subject`, `message`, `draft`, `updated_at`, `created_at`) values (test, testgdsgds, 0, 2015-05-24 16:03:59,...

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

php,laravel,laravel-4
According to this, if you do the following <?php // app/routes.php Route::get('/', function() { return View::make('form'); }); Route::post('handle-form', function() { var_dump(Input::all()); }); We'll get the following: array(0) { } According to Dayle Rees, that is because files are stored in the $_FILES array and not in $_GET or $_POST. So...

Mailchimp returns true but email not in list of subscribers

php,laravel-4,mailchimp
Laravel 4.2 Mailchimp Library: https://github.com/hugofirth/laravel-mailchimp I have already created a list and added two subscribers in Mailchimp GUI. <?php $list_id = '******'; $email_address = '[email protected]'; $subscriber = MailchimpWrapper::lists()->subscribe( $list_id, array('email'=>$email_address) ); return Response::json ( [ 'response' => $subscriber ] ); ?> Response is true { "response": { "email": "[email protected]", "euid":...

Saving vs. submitting a form

html,laravel,laravel-4
I am working on an application process using Laravel 4.2. Users applying with my form need to be able to save their form input for later, or submit it. So right now I have two different buttons, Save and Submit. The key difference between saving and submitting would be a...

Self Join in Eloquent - How To Call

laravel,laravel-4,eloquent,laravel-5
I recently asked a question regarding a self join SO I got a great answer but I'm not sure how to call it. I need to do this query: SELECT t2.title FROM products t1, products t2 WHERE t1.id = $id AND t2.color_id = t1.color_id AND t2.id != $id I now...

Set base path in laravel 4

laravel-4
I have developed one simple application in laravel 4 using artisan commands.It's working fine using php artisan serve command line via port.But i wish to run by public folder like localhost/myapp/public.but my form are not posting in to any controller methods due to path Form {{ Form::open(array('post' => '[email protected]')) }}...

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

php,class,oop,laravel-4
I am trying to pass in an array into my new class so that I always have access to the variable. To do this: class AppointmentData { private $date = []; public function __construct(Array $date) { $this->date = $date; } public function foo() { dd($this->$date); } } Then: $appointmentData =...

Nested comments with Laravel

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

Boostrap thumbnail slider load dynamic conent

php,jquery,twitter-bootstrap,laravel-4
I have a thumbnail slider on index page <div class="productslider carousel slide data-slider" id="prod158"> <div class="carousel-inner"> <div class="item active"> <ul> <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> </ul> </div> <a data-slide="prev" href="#prod158" class="left carousel-control"> <span...

Access a protected field from queried Eloquent object

php,laravel,laravel-4,eloquent
I query an entity: $trip_redirect_id = Trip::whereUniqueToken($unique_token)->select('id')->get(); and try to get the id value with $trip_redirect_id->id or $trip_redirect_id['id'] but I get exception that the field is not present. When I dump the $trip_redirect_id object, I can see the id and it's value and they are correct (I checked with the...

Laravel orderBy on with

php,laravel,laravel-4,eloquent,laravel-5
I have problem with eloquent query. I am using one to Many Relationship to get 'MenuItems' With the 'Menu'. I want to get all menuItems of a particular menu in sorted by 'sort_order' field Using the code below: Menu::where('slug', 'main-navigation')->with('MenuItems')->orderBy('MenuItems.sort_order', 'asc')->get(); It is not working, is it possible to do...

Laravel 4 inside Wamp does not work

php,laravel-4
I want to use Laravel in my projects, but I faced a problem. Namely, I'm already using WAMP server as local server... I followed the instructions for installing Laravel inside WAMP... so I enabled openSSL first, then downloaded Composer, then tried composer command in the CMD, everything was fine so...

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

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

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

laravel-4,eloquent,pivot-table
I have a cars table, and a car_image table. I want to get all the cars that have NO images in the car_image. In my car model I am making a scope: public function scopeNoImages($query) { return $query-> ?? } How can I create a scope that will show only...

Laravel 5 __construct() argument passing error

laravel,laravel-4,laravel-5,laravel-validation
So I am trying to group all my validation rules into its respective files in folders for easy maintenance. Below is how my folder structures look: Project --app --config --(more folders) --domains ----App --------Entities --------Repositories --------Services --------Validators ----Core --------Validators So what I wanted to achieve is under Core\Validators I created...

Attachment downloaded in “File” format instead of pdf

pdf,laravel-4,email-attachments,file-format
I am sending an email with an attachment (pdf) through laravel.But the attachment when downloaded converts to "File" type instead of pdf... Heres my code $pdf_file_path = public_path() . '/user/invoices/invoice_' . $data['hp_transaction_id'] . '.pdf'; PDF::loadView('payment.payment-invoice', $data) ->setPaper('a4') ->setOrientation('portrait') ->setWarnings(false) ->save($pdf_file_path); Mail::send('emails.view-property-transaction-completed', $data, function($message) use ($pdf_file_path, $transaction) {...

Custom Column Names having spaces Laravel 4

php,mysql,laravel-4,query-builder
I want to use a custom column name that has spaces.How can I write the query for this using Laravel 4. I tried $org = Org::select('name as Organization Name')->where('id',$user->orgId); $org = Org::select('name as "Organization Name"')->where('id',$user->orgId); $org = Org::select('name as `Organization Name`')->where('id',$user->orgId); $org = Org::select('name as (Organization Name)')->where('id',$user->orgId); $org = Org::select('name...

Tinder Laravel matching between 2 models

php,laravel,laravel-4,eloquent,tinder
i have 2 tables namely users and employers . I would like to match them together like tinder style, which means that when both the user and the employer liked each other , they will each receive a notification . However i am not sure how would the relationship table...

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

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

jquery events on advanced datatables

jquery,laravel-4,datatables
I retrieve some records from database and showing in data table and i use jquery event .click on [Click to Pay] button it works fine in first page of the table but when i use table pagination next .click event on button didn't work This is my code $('.pay-btn').click(function...

JavaScript click function table cell only applied on the first row

javascript,jquery,laravel-4,blade
I had a JavaScript click function on a table row, but when I click it, the function only works on the first row. How do I fix this? <script type="text/javascript"> $(document).ready(function(){ $('#detpanel').hide(); $("#showdet").click(function(){ $('#detpanel').slideDown(500); }); $("#hidedet").click(function(){ $('#detpanel').slideUp(500); }); $('#showdet').hover(function(){ $(this).divhover("background-color", "yellow"); }); }); </script> <tbody> <?php $i = 0; ?>...

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

php,laravel-4
my first code line is Session::put('step_1', array('security' => 'yes')); 2nd is $vat=10; \Session::push('step_1.vat',$vat); my current output: Array ( [security] => yes [vat] => Array ( [0] => 10 ) ) My Desired Output: Array ( [security] => yes [vat] => 10 ) hot to achieve my desired output, please suggest,...

Adding to a collection?

laravel,laravel-4,eloquent,laravel-5
This is a simplified version of what I need to do, so the below may seem pointless. I get a row with: $firstProduct = Product::first(); I also get all out with: $ data = Product::all(); I need the first product to be in position 5 so I: $data = $data->splice(5,...

Relationship results automatically coming out?

laravel,laravel-4,eloquent,laravel-5
I have a series of relations on my model, here is one of them. class Product extends Model{ public function user(){ return $this->belongsToMany('\App\User'); } } I get all rows with: $data = Product::all() And these are looped through like so: foreach ($data as $value) { var_dump($value->title); } My understanding was...

Eloquent sortBy - Specify asc or desc

php,arrays,laravel-4,eloquent
Trying sort my eloquent collection: $collection->sortBy('field'); There is no information in Laravel 4's docs on how to choose descending or ascending for this sort method. Is it possible?...