w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » LARAVEL » Page 1
Laravel link to action destroy not working
Because you need post form with pseudo delete http method like in the docs: laravel.com/docs/4.2/html#opening-a-form. Unless you're not using default laravel routes of course. – Jarek Tkaczyk This was the solution, thank you!

Categories : Laravel

Laravel: API with OAuth 2.0
I don't know Laravel, but in general, the authorization endpoint (in your case, http://somedomain.com/oauth/authorize) behaves as described in RFC 6749. The specification defines four flows. If you use Authorization Code Flow among the flows, you should access the authorization endpoint with the following request parameters. response_type=code (required) client_id={your-client-id} (required) sc

Categories : Laravel

Laravel URL Route get 2 parameter
In URL::route, you should use an array as the second parameter, like this: <a href="{{URL::route('admin-photo-delete', [$id, $photo->id] )}}">Delete Photo</a>

Categories : Laravel

Installing Laravel via the Laravel installer
The PATH environment variable tells your system where to look when you run a command. By default ~/.composer/vendor/bin will not be in your PATH. Therefore, if you just attempt to run the command laravel after installing it via composer, your terminal will give you an error saying the command is not found. But if you use the entire path to the command (~/.composer/vendor/bin/laravel), it will exec

Categories : Laravel

db seeds from a package Laravel 4
According to the documentation, the only available option for this function is --class. What you can do is create a class that gets data from your package.

Categories : Laravel

How to get all related items like "with" in Laravel?
I don't know what you want exactly but i think you need user relative more information if you want user relative in formation so please try this you get all information about user $users = User::all();

Categories : Laravel

Knockout js + Laravel localization
Laravel does not have build in functions for translations. If you want to use messages in other languages you will have to add them to the language files.

Categories : Laravel

Laravel 4 search - in view, show value submitted in form
Controller: public function postSearch() { $search = Input::get('search'); $events = DB::table('events') ->where(function($query) use ($search) { $query->where('title', 'LIKE', '%' . $search . '%') ->where('date','>=', DB::raw('CURDATE()')); }) ->orderBy('date', 'DESC') ->get(); $this->layout->content

Categories : Laravel

Laravel Model Relationship
In the example Step::find(1)->connections()->connectionSteps(), you are thying to access relation connectionSteps of the Step which isn't defined. That's why you get 'Call to undefined method ' as this is Connections relation. You can achive this by using eager load which will load multiple relationships at one time: Step::with(array('connections', 'connections.connectionSteps'))->find(1);

Categories : Laravel

How can I use variable from one public function in another public function in Laravel?
From your Pastebin example I can see that you already tried using Sessions. That's definitely the way to go for keeping data over multiple requests (without storing it in a persistent fashion) store filename Session::put('filename', $filename); retrieve filename $filename = Session::get('filename'); remove filename from session Session::forget('filename'); Alternatively you can flash the

Categories : Laravel

Running "exists" queries in Laravel query builder
see here http://laravel.com/docs/4.2/queries Scroll down to Exists Statements, you will get what you need DB::table('users') ->whereExists(function($query) { $query->select(DB::raw(1)) ->from('table1') ->whereRaw("id = '100'"); }) ->get();

Categories : Laravel

How to overwrite Laravel's database connection
The problem is, that Laravel establishes a connection using the config and then keeps it in memory. If you want to do it by setting new connection variables, you have to reconnect after making changes. (also note that you can set the config directly with the awesome dot notation) Config::set('database.connections.customers.database', 'db_A'); DB::reconnect('customers'); However the better way,

Categories : Laravel

Laravel 4.2: Can't Use Transformer with DB::Raw Query
First off, don't use all() on a DB::select. The select method does execute the query as soon as it's called. Also all() is for Eloquent models only. However the bigger problem here, is how a Query Builder result is structured. Its an array (of all rows) filled with objects (the individual row, with properties for each column) So that means, passing it to your transform method and then accessing

Categories : Laravel

Laravel named routes won't work on wampserver
Route::get('/', 'HomeController@showWelcome'); Route::get('post/listing', array('uses'=>'PostController@listing','as'=>'post.listing')); Route::get('post/single', array('uses'=>'PostController@single','as'=>'post.single')); notice the ' around route names.

Categories : Laravel

homestead.rb:63:in `configure': undefined method `each' for nil:NilClass (NoMethodError)
You need to have a database added to your Homestead.yaml: --- ip: "192.168.10.10" memory: 2048 cpus: 1 authorize: ~/.ssh/id_rsa.pub keys: - ~/.ssh/id_rsa folders: - map: ~/Code/testprogram to: /home/vagrant/testprogram sites: - map: test.app to: /home/vagrant/test/public databases: - name: testprogram variables: - key: APP_ENV value: local

Categories : Laravel

laravel checking pivot returns error contains() on a non-object
$attendee->scheduled_program_segments is a m-m relation, so obviously it returns null, because Laravel 4+ relations need to be camelCased in order to work as dynamic properties (that is what you're trying to do). So you can either rename your relation to scheduledProgramSegments() and then call it: $attendee->scheduledProgramSegments // or $attendee->scheduled_program_segments // yes,

Categories : Laravel

How to grab data from another table with this relationship setup?
Assuming you have correct relationship, it should be rather something like that: @foreach ($vendor->cities as $city) {{ $vendor->city->city}}, {{$vendor->city->state->name}} @endforeach In above code you display for one vendor city with state name and instead of: Vendor::with('cities')->get(); you should rather use: Vendor::with('cities.state')->get();

Categories : Laravel

Laravel: can't pass variable to the view
The problem is for index method where you display home.index This file include home.main and in this file you use $batteries variable. You should not include home.main template here or add extra checking if $batteries are set: @if (isset($batteries)) <ul class="list-group"> @foreach ($batteries as $battery) <li class="list-group-item">{{{ $battery->name }}}</li>

Categories : Laravel

oauth-4-laravel - Just need a simple Application Only Auth and search/tweets.json
I realise that my answer isn't referring to the library you're using, but I can't comment on things yet. You can use Guzzle to do this with Guzzle's OauthPlugin. It should be fairly easy. Laracasts did an example connection to Twitter. I believe that uses Guzzle 3 or 4. The most recent Guzzle is Guzzle 6. I had a bit of trouble integrating that with Laravel 5. But have a look at how I did it, i

Categories : Laravel

Load cities from state laravel
You can use ajax with jQuery. In your view set an event when the state change, like this: $(document).on('change', '#state_id', function (e) { // empty the select with previous cities if we have. $('#cities').empty(); $.ajax({ type: "POST", dataType: "json", // actions is a controller // cities

Categories : Laravel

Eloquent "grandfather" relashionship condition
Easy way, assuming Book belongsTo School: Page::whereHas('book', function($query) { $query->where('school_id', '=', 1); })->get(); complete solution: Page::whereHas('book', function($q) { $q->whereHas('school', function ($q) { $q->where('id', '=', 1); }); })->get();

Categories : Laravel

Stripe: add a one off payment to a subscription
You can use the invoice item object for this purpose. The invoice item can be added to a subscription and would be payed during the next subscription billing cycle. Alternatively you can also just create a charge a la carte. This would have nothing to do with the subscription directly, and simply charged the card for the purchase. Invoice Item: https://stripe.com/docs/api#create_invoiceitem Cha

Categories : Laravel

Laravel make multiple routes to have common parameter
Sure thing, except you don't do it in the routes. It's called a view composer, and it works like this: // adds shopping cart info to the view View::composer(['some.view.1', 'some.view.2'], function($view){ $shopping_cart_info = ProductController::getShoppingCartInfo(); $view->with('shopping_cart_info', $shopping_cart_info); }); Now, the views "some.view.1" and "some.view.2" will both

Categories : Laravel

Laravel migration won't reference second foreign key
Everything looks ok to me. Furthermore, since it only complains about the second part, the categories foreign key must've worked. I would think the brands table doesn't exist or there is something wrong there. Does the table exist and does it have a primary key "id"? I also use $table->engine = 'InnoDB'; at the beginning, because MyISAM doesn't support foreign keys as of now. I don't think

Categories : Laravel

Creating one-to-many relationship between a model and a db table
Create a relationship without an Eloquent Model does not make sense. You can do that without Laravel by using database foreign keys. The purpose of an Eloquent relationship (and of an ORM in general) is to get structured objects when calling the relationship. $answers = $poll->answers; echo $answers->last()->title; We use OOP in order to not manipulate raw datas but objects, it is gene

Categories : Laravel

How to get Route in Middleware in Laravel
Remove your constructor/put it to default like; public function __construct(){} Try accessing the route via the handle method like so; $request->route(); So you should be able to access the action name like so; $request->route()->getActionName(); If the route return is null be sure you have registered the middleware within the App/Http/Kernel.php, like so; protected $middlewar

Categories : Laravel

What is the equavelent of mysql : SET in laravel 4.2?
if you want to replace bellow mysql query - UPDATE managerStock SET amount = amount + $productAmount WHERE manager_id = '$receiverID' and product_id='$productID' Possible answer could be - $dbData = DB::table('managerStock')->where('manager_id', $receiverID)->where('product_id', $productID)->first(); $dbData->amount = $dbData->amount+$productAmount; $dbData->save(); for mor

Categories : Laravel

Laravel join two table from two columns
Why don't you use the raw SQL statement like this if you already have it? $data = DB::Select("SELECT s.date, CONCAT_WS(' ', NULLIF(u1.first_name, ' '), NULLIF(u1.last_name, ' ')) AS applicant, CONCAT_WS(' ', NULLIF(u2.first_name, ' '), NULLIF(u2.last_name, ' ')) AS app_by FROM stamp s LEFT JOIN users u1 ON s.applicant_id = u1.id LEFT JOIN users u2 ON s.app_by_id = u2.id;" );

Categories : Laravel

Laravel4 task to cron
To create a cronjob, you have to edit a file. It is pretty easy, run crontab -e to edit the cron file for the current user. Now just add a line to the file that opens: 0 * * * * php /full/path/to/your/application/artisan meeting:close Maybe you also have to specify the absolute path to your php executable Now save the file and you're all set. By the way, if you didn't know, you can run your

Categories : Laravel

Syntax error on Service Provider
It should be: $this->app->bind('MainPageInterface', 'MainPagesRepository'); or App::bind('MainPageInterface', 'MainPagesRepository');

Categories : Laravel

Creating a laravel ACL section
Is the $route parameter in the allowed helper a Laravel Route instance? Or simply the current URL? On the latter, you could do something like this in routes.php: if (allowed(Request::url())) { Route::group(["before" => "auth"], function () { $resources = Resource::where("secure", "=", true)->get(); foreach ($resources as $resource) { Route::any($resource->pattern, [

Categories : Laravel

Laravel Model Events dont fire
You are setting the event closure AFTER you are calling save on the model. You should be calling save after you define the event closure. public function gracias() { $client = new Client; $client->name = "name"; $client->lastname = "lastname"; $client->email = "email"; $client->phone = "phone"; Client::saved(function($client) { Log::info('on saved');

Categories : Laravel

Are there any disadvantages to not using blade and having the front totally decoupled from the back end in Laravel?
In my opinion there are a few advantages of AngularJS over blade and vice versa: Advantages blade: Laravel has some html helpers and form helpers. Laravel adds a token to a form for preventing csrf! When you open a form you can give a route to it. The method and the action are defined by blade based on the given route. With blade you can create macro's and view composers. When validating a form

Categories : Laravel

composer.json not loading forked repo
Even after you fork the repository, composer will still try to resolve version 1.*. So it will get your forked repository, but it will look up the latest 1.* version. Even if you put * as the version requirement, it will still get the latest tag, not the latest commit. If you want the latest commit, you can put dev-master as the required version string. Alternatively you could modify the composer

Categories : Laravel

All checkboxes are checked in edit mode
Your code means that for each location, if $location->city has any value, the checkbox named city[] should be marked as checked (since any non-null or non-zero value in city will evaluate as true). Either change the name of the checkbox from city[] to the field holding the true/false value in locations that should determine the state of the checkbox; or, change the name from city[] to somethin

Categories : Laravel

What would be the best way to set up this type of many relationship?
If you have the vendor_id in the vendor location table, you don't need a vendor_location_id in the vendor table. Heres how I would do it: Vendors • id • name Cities • id • name • state_id States • id • name VendorCity • id • vendor_id • city_id then the relationships: class Vendor extends Eloquent { public function cities() { return $this->belo

Categories : Laravel

One to many relationship count - difference in accessing relationship
Assuming your schema reflects one record / model per visit in your visits table, The best method would be to get rid of the visitsCount() relation and only use $entry->visits->count() to retrieve the number of visits to the entry. The reason for this is that once this relation is loaded, it will simply count the models in the collection instead of re-querying for them (if using a separate r

Categories : Laravel

Difference between `pattern` and `where`
you can define Global Patterns using pattern If you would like a route parameter to always be constrained by a given regular expression, you may use the pattern method: Route::pattern('id', '[0-9]+'); Route::get('user/{id}', function($id) { // Only called if {id} is numeric. }); Route::get('product/{id}', function($id) { // Only called if {id} is numeric. }); while using where you n

Categories : Laravel

Use Eloquent to attach array to query
Laravel provides in ways to make json from objects. The first and simplest is the eloquent toJson() method: $likes = Category::orderByRaw("RAND()") ->leftJoin('likes', 'likes.item_id', '=', 'categories.id') ->take(9) ->get() ->toJson(); $likes is now json. Second method: If you return a model from a controller or a routecallback f

Categories : Laravel




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.