I have created a Package in laravel and i am not able to include the package between header and footer of the page. Please find the code below,
$this->loadViewsFrom(__DIR__.'\views','details');
How to include the package between header and footer section of a website ?
Please help me to resolve the issue.
The package have the following structure as show below
--Root
--packages
--events
--details
--src
--assets
--Models
--Request
--Views
routes.php
DetailsServiceProvider.php
DetailsController.php
composer.json
In your service provider you will register a view namespace using the code:
$this->loadViewsFrom(__DIR__.'\relative\path\from\service-provider','details');
Now you would be able to load files using view('details::template-file') which will look for the path \relative\path\from\service-provider\template-file.blade or by including them in other blade files: #include('details::template-file')
Related
Folder structure:
Livewire
- Things
- Addthing.php
Blade file
#livewire('things.addthing')
is unable to locate it: Unable to find component: [things.addthing]
Without subdirectory, this works fine as:
Livewire
- Addthing.php
.
#livewire('addthing')
How do I get Livewire components to work in a subdirectory?
It should work like this, did you also update your namespace to match the path?
For example:
namespace App\Http\Livewire\Things;
I referenced it as #livewire('things.addthings') in the blade and it worked maybe check your typo.
I want to add a carousel plugin into laravel.
https://github.com/OwlCarousel2/OwlCarousel2
so I run npm install --save owl.carouse and add following code into index.blade.php
<script src="/node_modules/owl.carousel/dist/owl.carousel.js"></script>
The owl.carousel.js is inside my project, but when I run npm run watch, and look at the browser, there show an error in the console:
GET http://127.0.0.1:8000/node_modules/owl.carousel/dist/owl.carousel.js 404 (Not Found)
Why is that?
You should not import it through a script tag. Add it in your bootstrap.js file
require('owl.carousel');
require() will use the node_modules as the root dir
You can of course use require in any other .js file that you then import through a script tag.
If you are using VueJs you do at the top of the vue component
import owl from 'owl.carousel'
Your web server does not have access to node_modules directory.
You'd better use gulp to copy and bundle it to public directory.
Or else if you want, you can do it manually. Copy the script to the public directory.
I usually make asset/js directory under the public and then copy owl under it.
You will have:
<script src="/asset/js/owl.carousel/dist/owl.carousel.js"></script>
Add this line in your main .scss file:
#import '~owl.carousel/dist/assets/owl.carousel.css';
Compile the css with npm run dev
You can repeat these steps for your javascript files
Edit:
If you do not make use of Laravel mix yet, read this documentation first. https://laravel.com/docs/5.6/mix
While using the above package in laravel I'm getting error as
"Class 'Kazist\ResellerClub\APIs\Controller' not found"
Please suggest me a solution how to call the reseller club api "url" in the controller.
$request = file_get_contents('https://httpapi.com/api/domains/available.json?auth-userid=USER_ID&api-key=API_KEY&domain-name='.$slds.'&tlds='.$tlds.'');
Please help me with a solution how to declare the domain-name and tlds from the above url in laravel.
For package installation:
From terminal go to your project's root directory and run this command:
composer require kazist/resellerclub-php-sdk
And then after successful installation one new folder called kazist will be created inside project's vendor directory.
For using api calls you need to use Guzzle http client https://github.com/guzzle/guzzle or use this link.o
Edit
Yourcontroller.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use
class Yourcontroller extends Controller
{
$resellerClub = \Kazist\ResellerClub\ResellerClub(<userId>, <apiKey>, true); // Last argument is for testmode.
// Get Available TLDs
$resellerClub->domains()->getTLDs();
// Check Domain Availablity
$resellerClub->domains()->available(['google', 'example'], ['com', 'net']); // This will check google.com, google.net, example.com and example.net
}
I am new to using composer, I have it installed, created composer.json file. Installed bigcommerce api using these instructions: https://github.com/bigcommerce/bigcommerce-api-php
When I try to run "use Bigcommerce\Api\Client as Bigcommerce" I am getting error class not found.
I am using localhost and my file structure is:
testsite
src-> contains all classes including Client.php
vendor -> bigcommerce -> api -> the api files,
api.php -> my test file trying to connect to api
I have not changed any composer files, I have looked into autoloading. As I said before it is first time using composer.
Please read the documentation of Composer here: https://getcomposer.org/doc/00-intro.md Pay attention to the last couple of paragraphs, "Using Composer" and "Autoloading". Did you follow the procedures in your code?
I have installed Laravel and began trying to write an app. I made some directories for my assets in the same directory as /app. But when I try to visit an image in my localhost for example: http://localhost/assets/images/image.png
I've also tried it on: http://localhost/app/assets/images/image.png
I ran into the problem when I was trying to set a background image in a view, and it kept going to 404.
This is what my app looks like under app/
->app
->assets
->commands
->config
->controllers
->database
->lang
->models
->start
->storage
->tests
->views
app.txt
routes.php
filters.php
But I get errors about requests. I have double checked that the url is correct.
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
You have to put all your assets in app/public folder, and to access them from your views you can use asset() helper method.
Ex. you can retrieve assets/images/image.png in your view as following:
<img src="{{asset('assets/images/image.png')}}">
You have to do two steps:
Put all your files (css,js,html code, etc.) into the public folder.
Use url({{ URL::asset('images/slides/2.jpg') }}) where images/slides/2.jpg is path of your content.
Similarly you can call js, css etc.
Besides put all your assets in the public folder, you can use the HTML::image() Method, and only needs an argument which is the path to the image, relative on the public folder, as well:
{{ HTML::image('imgs/picture.jpg') }}
Which generates the follow HTML code:
<img src="http://localhost:8000/imgs/picture.jpg">
The link to other elements of HTML::image() Method: http://laravel-recipes.com/recipes/185/generating-an-html-image-element
{{ asset('js/jquery.min.js') }}
//Full Path http://127.0.0.1:8000/images/slides/2.jpg
Do Not Add Public folder name