laravel-4

Remove HTML tags from Strings on laravel blade

自古美人都是妖i 提交于 2019-12-04 22:19:14
I want remove HTML tags (all) from a string on laravel blade ... code {!! \Illuminate\Support\Str::words($subject->body, 5,'...') !!} output (example) <p>hassen zouari</p> I want that it be like this hassen zouari Try to use strip_tags() function: http://php.net/manual/en/function.strip-tags.php Update: Try to do something like this in a controller: $taglessBody = strip_tags($subject->body); Then pass this variable into a blade template and use it instead of $subject->body . You can use strip_tags($yourString); to strip the html tags. In blade you could achieve this by {{ strip_tags(

Laravel 4: loading an old library: how?

最后都变了- 提交于 2019-12-04 22:16:28
问题 I have an old library (phpquery) that I'd like to include in my project. I've put it inside vendor, but it doesn't work, as it's not PSR-0 compliant. I don't want it to load for every request, so I didn't put the require inside bootstrap autoload.php. I don't even know, how I can get the root of the app. Running path() gives me a URL, not what I'm after. So how can I do that? 回答1: You can create a libraries directory just like in laravel 3 and include it in your class loader. You can do this

Deploying Laravel 4 on shared hosting server (hostgator)

旧时模样 提交于 2019-12-04 21:59:59
I would appreciate your help. I really don't know where else to turn to. I can't deploy a L4 app to Hostgator. I read the guide on the forums, but my shared HG account already has many apps under public_html so deleting it would be catastrophic and a risk I cannot afford to play with. Is there a way to deploy L4 app like any other normal apps? What I am trying to do is the following: home/myuser/public_html/domain.com/laravel/ <--- where the app should live home/myuser/public_html/domain.com/laravel/dev <--- dev environment in both of these folders there is a separate git repository (via ssh).

Laravel testing with PHPUnit and Mockery - Setting up dependencies on Controller test

一个人想着一个人 提交于 2019-12-04 21:31:52
问题 After finally getting my stupid simple test to pass, I have a feeling that I'm not doing it correctly. I have a SessionsController, that is responsible for displaying a login page and logging a user in. I have decided not to use facades so that I wouldn't have to extend Laravel's TestCase and take a performance hit on my unit tests. Therefore, I have injected all the dependencies through the controller, like so - SessionsController - Constructor public function __construct

Laravel get related models of related models

纵饮孤独 提交于 2019-12-04 20:49:07
问题 I have a RepairRequest model, which is associated with a Vehicle. class RepairRequest extends \Eloquent { public function vehicle() { return $this->belongsTo('Vehicle'); } } class Vehicle extends \Eloquent { public function requests() { return $this->hasMany('RepairRequest'); } } I would like to get all RepairRequests for the vehicle associated with a given RepairRequest, so I do return RepairRequests::find($id)->vehicle->requests; This works fine. However, RepairRequests have RepairItems: //

Laravel 4 eager loading and categories, subcategories, articles

微笑、不失礼 提交于 2019-12-04 20:42:39
Hi i thought i can handle this myself, but actually i don't know how to bite it. I am trying to categorise my programs. There will be only 2 levels of categories: 1 CATEGORY 2 |-Subcategory I want it to be as simple as possible. - program can belong to only one subcategory, - categories can have many subcategories, - subcategories can have many programs, Of course i would like to list all programs from subcategories, when someone choose a main category. I am also not sure about my current database tables structure and relationship in models. Tables in database: programs : id, title,

update pivot table in case of many to many relation laravel4

假装没事ソ 提交于 2019-12-04 20:08:43
问题 I have started working with Laravel4 recently. I am facing some problem while updating pivot table data, in case of many to many relation. The situation is: I have two table: Product , ProductType . The relation between them is Many to many . My Models are class Product extends Eloquent { protected $table = 'products'; protected $primaryKey = 'prd_id'; public function tags() { return $this->belongsToMany('Tag', 'prd_tags', 'prta_prd_id', 'prta_tag_id'); } } class Tag extends Eloquent {

Defining the email address for the Mail::send() method

落花浮王杯 提交于 2019-12-04 19:56:36
问题 Apologies if I'm missing something here as I'm new to Laravel but when I send a closure to the Mail::send() method to define the mail recipient, it works fine if the email address is available the global scope, like this: Mail::send('frontend.emails.default', $data, function($message) { $message->to(Input::get('email'))->subject('Hi'); }); But how can I pass a value in that's scoped to the calling method? For example: $user = User::find($id); Mail::send('frontend.emails.default', $data,

Angular JS + Laravel 4: How to compile for production mode?

一笑奈何 提交于 2019-12-04 19:31:12
So i have watched the 5 part youtube videos by David Mosher about Angular JS (vids great by the way). In the part 2 ( http://www.youtube.com/watch?v=hqAyiqUs93c ), it has a practical mysql database usage which I almost wanted. I'm going to use AngularJS along with Laravel 4, but I had no idea which files I'm going to upload for the web hosting later . I'm trying to run the web app under "/public" folder in my root on localhost (localhost/public/) but the css and js points to the wrong directory (points to the root: '/css/style.css'). Another method I have tried is by copying all the files to

Laravel extend a vendor class installed from composer

回眸只為那壹抹淺笑 提交于 2019-12-04 19:10:16
问题 Hi I am using the following package https://github.com/jayhealey/Robots to add a different robots.txt file per environment I have on my application. However this is missing one method I am using on my application which is the crawl delay i.e. Crawl-delay: 3600 Now i have the following folder from the composer install of this package: vendor/healey/robots/src/Healey/Robots/Robots.php and this starts as so: <?php namespace Healey\Robots; class Robots {....} Now I want to be able to extend this