Deekshith

Member Since 2 Years Ago

Experience Points
12,600
Total
Experience

2,400 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
31
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

  • Community Pillar

    Earned once your experience points ranks in the top 10 of all Laracasts users.

Level 3
12,600 XP
May
14
2 days ago
Activity icon

Replied to Laravel Collection Always Returns An Object Instead Of An Array

@graeme1995 any solution you got it for this? i am facing the same problem. it would be really helpful if you paste the code here. i am getting correct array structure in first page but in second page i am getting in objects.

Activity icon

Replied to Merge Different Get Query Results With Pagination In Array Format

@jlrdw my answer is working only for page 1 and for page 2 again number identifier is showing like below,

{
    "current_page": 1,
    "data": {
        "36": {

				},
			"37" :{

			}
}
}

Can you please help to get the data in below format for data key?

{
    "current_page": 1,
    "data": [
         {

				},
			{

			}
]
}

i have used values() before but it is working only for first page but if use ?page=2 then it is showing in first format.


$final = $unique->sortByDesc('post_date')->values()->paginate(15);
May
13
3 days ago
Activity icon

Replied to Merge Different Get Query Results With Pagination In Array Format

@jlrdw thanks for the reply. solved this by adding values() like below,

 $final = $unique->sortByDesc('post_date')->values()->paginate(15);
Activity icon

Started a new Conversation Merge Different Get Query Results With Pagination In Array Format

i am using corcel package to get wordpress posts and i am getting all the posts which matches some categories like below,

$categories = ['current-affairs-2','current-events-2','editorials'];

$related = new Collection([]);
            // return $pagedetail->assignedcategories->first();
    
            foreach($categories  as $cat)
            {
            
                $categorydetail = Taxonomy::slug($cat->category)->first();
                
                $catposts =  $categorydetail->posts()
                                    ->where('post_status', 'publish')
                                    ->whereYear('post_date',$year)
                                    ->whereMonth('post_date', $month)
                                    ->newest()
                                    ->select('ID','post_title','post_date','post_date_gmt','post_status','comment_status','post_name','post_modified','post_modified_gmt','guid','post_type')
                                    ->get();
    
                $related = $related->merge($catposts);
            }
    
            $unique = $related->unique('ID');
            
            return $final = $unique->sortByDesc('post_date')->paginate(20);

Above code returning like below format,

{
    "current_page": 1,
    "data": {
        "36": {

				},
			"37" :{

			}
}
}

but i want response in below format,

{
    "current_page": 1,
    "data": [
         {

				},
			{

			}
]
}

like this i should get array structure for data key but if i use merge of collection then i am not getting array structure. if use only one record without forleach then i will get array structure.

any help?

May
11
5 days ago
Activity icon

Replied to Convert Doc Or Docx File To Pdf

@sr57 i am not able to get what is this ? as i have not installed this yet,

'unoconv.binaries' => '/opt/local/unoconv/bin/unoconv',
Activity icon

Replied to Convert Doc Or Docx File To Pdf

@sr57 thank you. do you have any sample to setup this in bluehost shared server? as i have shared server i dont think i can install extra software in server.

Activity icon

Started a new Conversation Convert Doc Or Docx File To Pdf

Hi, i am trying to convert doc to pdf and i have used phpoffice for this but this is full of bug as some contents are missing styles or not working, fonts are not working . i want at least 90% similarity. please help me out how to convert doc to pdf ?any ideas?

May
08
1 week ago
Activity icon

Started a new Conversation Regular Expression With Hyphen In Shortcode

i have a shortcode like below

[Linkref 1]
[Linkref 2]

and i have a code like below,

$results = preg_match_all('/\[LinkRef (\d+)]/', $contentget, $matches);

Above code is working fine and it results array like below,

['1','2']

Now i want to add a separator between the numbers like below,

[Linkref 1-2-3]

But above regexp is working only for digits not for other characters.

how to alter above regexp so that output should be like below,

['1-2-3']
Activity icon

Replied to Replace Shortcode With Html Of Specific Data

@rodrigo.pedra Hi, I have one doubt suppose if i want to add another shortcode like below how to alter this to check data dynamically

$figresults = preg_match_all('/\[Figures (\d+)]/', $contentget, $matches);
    $refresults = preg_match_all('/\[Reference (\d+)]/', $contentget, $refmatches);

        if ($figresults === false || $figresults === 0) {

          if ($refresults === false || $refresults === 0) {
              return $contentget;
          }

            return $contentget;
        }

        [$placeholders, $figureids] = $matches;
        [$refplaceholders, $refids] = $refmatches;

        $figures = ArticleFigure::query()
       ->whereKey($figureids)
       ->get();

        if ($figures->isEmpty()) {
            return $contentget;
        }

        foreach ($placeholders as $index => $placeholder) {
            $figure = $figures->find($figureids[$index] ?? 0);

            if ($figure) {
                $imageUrl = url('/article-figure/'.$figure->figureuuid);

                $content = Str::of('<img src="##URL##" alt="##ALT##" class="img-responsive"><p>##TEXT##<p>')
               ->replace('##URL##', $imageUrl)
               ->replace('##ALT##', $figure->title)
               ->replace('##TEXT##', $figure->content);

                $contentget = str_replace($placeholder, $content, $contentget);
            }
        }

Here if figures not found then it will return empty set. in references section figures shortcodes will be empty but it should display references shortcode data. i cant pass type parameter too in function becuase all are dynamic here so. any suggestion?

May
07
1 week ago
Activity icon

Replied to Replace Shortcode With Html Of Specific Data

@rodrigo.pedra great explanation thank you so much for sharing. :-)

Activity icon

Replied to Replace Shortcode With Html Of Specific Data

@rodrigo.pedra Thank you so much for the reply. i have some doubts.

What is $placeholders here and also,

if i store html data directly in db for each figure id then i can directly fetch right ? instead of this?

$content = Str::of('<img src="##URL##" alt="##ALT##" class="img-responsive"><p>##TEXT##<p>')
                ->replace('##URL##', $figure->url)
                ->replace('##ALT##', $figure->text)
                ->replace('##TEXT##', $figure->text);

Thank you

Activity icon

Started a new Conversation Replace Shortcode With Html Of Specific Data

Hi, i have created some shorcodes like below,

[Figures 10]
[Figures 11]

Here 10 and 11 are figure id's and every figure id has some html data.

Now i want to replace [Figures 10] and [Figures 11] with the respective HTML data. Example:

<p>Some text goes here, lorem ipsum lorem ipsum</p>
[Figures 10]

lets say [Figures 10] has html like below,

<img src="" class="img-responsive">
<p>figure text<p>

So now the final content after render will be like below,

<p>Some text goes here, lorem ipsum lorem ipsum</p>
<img src="" class="img-responsive">
<p>figure text<p>

i am using below code to find all figure id's present in the content,

preg_match_all('/\[Figure\s(.*?)\]/', $contentget, $matches);
$figureids = $matches[1];

in above code i will get all figure id's but i am not getting how to replace shortcode from this data.

now i want to replace shortcodes with shortcode content which i will fetch from db. Thank you.

May
06
1 week ago
Activity icon

Replied to Auto Login From External Android App To Laravel Web App

@corvs Thank you. Yes in this case i should use session. i will use the api for cart part. for checkout i will pass api returned user details to payment gateway.

Activity icon

Replied to Incorrect Datetime Format

@davy_yg

$converteddate = date('Y-m-d H:i:s' strtotime($request->coupon_start));
echo $converteddate;
Activity icon

Replied to Auto Login From External Android App To Laravel Web App

@corvs one of my clients has a requirement like this. they dont have bandwidth to work on app now so for time being they have given above requirement and also we have ready ecommerce modules which can be used for shopping. Do you think explained steps are enough?

Activity icon

Replied to Auto Login From External Android App To Laravel Web App

Yes. here user specific page is lists of items to purchase. flow will be like this. every user has some loyalty points in mobile app which can act as discount . so once user clicks the "Shop Now" button laravel web page will open inside the app. i will get user related information along with loyatly points so now using the points i will display the total payable amount by deducting the discount amount as well.

Activity icon

Replied to Auto Login From External Android App To Laravel Web App

@corvs Thank you. So the steps will be like below,

  1. Once user clicks the button in mobile app. i will call laravel post api to generate the signed URL . Parameters for POST api are,
stored token in android,

  1. So once i received the token i will create the Signed URL using token parameter. now i can return the signed URL as a response along with status
  2. In app once response received i can redirect to that signed URL.
  3. in laravel i will write a route for that signed URL and fetch the user token.
  4. Now using that token i will call mobile app backend API using that token so in mobile app they will check is this valid token and returns required user info
  5. once user token verified from mobile app they will send the loyalty points and using that loyalty points i will reduce the price of catalog products. Example if item1 has price 150 and if user A has loyalty points of 50 then in products listing i will display item 1 price as 150 - 50 = 100.

This flow is fine right? Thanks for the reply.

Activity icon

Replied to Auto Login From External Android App To Laravel Web App

@corvs this solution sounds good. but the client comes from mobile app so signed URL should be created from mobile app which will be not compatible with laravel. if they can send the auth token which is stored in client android storage to laravel web app i can use that from laravel.

Activity icon

Started a new Conversation Auto Login From External Android App To Laravel Web App

I have a requirement like below,

users normally logs in using mobile app which is Android/IOS now there be a button to check the catalog or items to purchase once user clicks that button it will redirect to web page which is built on laravel. in android they will have auth token so i want to pass that token to laravel web app where i will use that token to fetch the orders history and loyalty points or some other user details in laravel web app. how to pass that auth token, if user opens the website inside the app itself? if stored auth token sent from android then i can use that token and call the api to fetch the details of that user in laravel application. Any suggestions would be helpful.

Apr
29
2 weeks ago
Activity icon

Replied to Filter Items From Category In BelongsToMany

@frankielee ya i got it i replaced the code like below and it is working now,

$journals = Journal::query();
    if(isset($_GET['category']))
    {
      $categories = $_GET['category'];
			$catslugs = collect(explode('_', $categories))
										    ->map(fn($i) => trim($i))
										    ->all();
		 $journals->with('categories')->whereHas('categories', function ($query) use($catslugs){
				        	$query->whereIn('categories.slug',$catslugs);
				    })->get();
    }
    return $journals->get();
Activity icon

Replied to Filter Items From Category In BelongsToMany

@automica thank you for the replay. but it is same error

Error
Call to a member function getRelationExistenceQuery() on array

my controller code is like below,

$journals = Journal::query();
    if(isset($_GET['category']))
    {
      $categories = $_GET['category'];
       $catslugs = explode('_', $categories);

       $journals->whereHas(['categories' => function($q) use($catslugs) {
            $q->whereIn('categories.slug',$catslugs);
       }]);
    }
    return $journals->get();

Journal.php modal code is,

public function categories() {
        return $this->belongsToMany(\App\Models\Category::class, 'journal_categories')->withTimestamps();
    }

Also if i remove whereHas and add with then it is working but it is displaying non matched data with empty set,

//replace whereHas to with
$journals->with(['categories' => function($q) use($catslugs) {
            $q->whereIn('categories.slug',$catslugs);
       }]);

Response will be like below,

[
  {
    "id": 1,
    "journal_uuid": "5826584",
    "title": "title goes here",
    "slug": "title-goes-here",
    "description": "<p>is an open-access and peer-reviewed online journal with Bimonthly print on demand compilation of issues published. The journal’s free full text is available online at http://www.cancertm.com</p>",
    "cover_photo": "1617363053cover.png",
    "user_access_type": "OPEN",
    "author_apc_type": "Disable",
    "acceptance_rate": "14",
    "final_decision_time": "40",
    "publication_time": "54",
    "apc": 0,
    "currency_type": "$",
    "user_price": 0,
    "deleted_at": null,
    "created_at": "2021-04-02T11:30:53.000000Z",
    "updated_at": "2021-04-02T11:30:53.000000Z",
    "categories": [
      {
        "id": 1,
        "category_name": "Medicine",
        "slug": "medicine",
        "cover_photo": null,
        "parent_id": 0,
        "meta_title": "Medicine",
        "meta_description": "Medicine",
        "meta_keywords": "Medicine",
        "deleted_at": null,
        "created_at": "2021-04-02T11:13:12.000000Z",
        "updated_at": "2021-04-02T11:13:12.000000Z",
        "pivot": {
          "journal_id": 1,
          "category_id": 1,
          "created_at": "2021-04-02T11:30:53.000000Z",
          "updated_at": "2021-04-02T11:30:53.000000Z"
        }
      }
    ]
  },
  {
    "id": 2,
    "journal_uuid": null,
    "title": "Test",
    "slug": "test",
    "description": "<p>Test Jorunal</p>",
    "cover_photo": "1619585670medicine.jpg",
    "user_access_type": "OPEN",
    "author_apc_type": "Enable",
    "acceptance_rate": "60",
    "final_decision_time": "60",
    "publication_time": "60",
    "apc": 800,
    "currency_type": "Rs.",
    "user_price": 800,
    "deleted_at": null,
    "created_at": "2021-04-28T04:54:30.000000Z",
    "updated_at": "2021-04-28T04:54:30.000000Z",
    "categories": []
  }
]

In above response i want to filter out empty categories because it wont match selected category

Apr
28
2 weeks ago
Activity icon

Started a new Conversation Filter Items From Category In BelongsToMany

I have a tables like below,

journals

id, name, uuid

categories

id,name,slug

journal_categories

id,journal_id,category_id

In journal.php model

public function categories() {
        return $this->belongsToMany('\App\Models\Category'::class, 'journal_categories')->withTimestamps();
    }

Now i want to filter the result based on category slug

i have a query like below,

$journals = Journal::query();
//input is category=cancer_medicine
if(isset($_GET['category']))
    {
      $categories = $_GET['category'];
       $catslugs = explode('_', $categories);
//output is ['cancer','medicine']

       $journals->whereHas(['categories' => function($q) use($catslugs) {
            $q->whereIn('categories.slug',$catslugs);
       }]);
    }
    return $journals->get();

But i am getting below error.

Error
Call to a member function getRelationExistenceQuery() on array

How to filter journals by category so that only assigned category journals should be displayed in result.

Apr
27
2 weeks ago
Activity icon

Started a new Conversation Fetach WpProquiz Wordpress Plugin Question And Answer In Laravel

i have wordpress site and also i am working on api in laravel and communicating with wordpress DB. i am using corcel package to fetch data and all. now in wordpress i have quiz plugin (wpproquiz). to fetch the questions i am passing the quiz id using below query,

preg_match('/\[WpProQuiz\s(.*?)\]/', $postdetail->post_content, $matches);
  $quizids = $matches[1];

  $getquestions = DB::connection('connectionname')->table('wp_pro_quiz_question')->where('quiz_id',$quizids)->get();

And all other fields are working fine. when i checked the answer_data column i found that all options are serialized and when i used below code to display unserialized data ,

 $answers = unserialize($que->answer_data);
 dd($answers);

Response is,

array:4 [▼
  0 => __PHP_Incomplete_Class(WpProQuiz_Model_AnswerTypes) {#1467 ▼
    #_answer: "a) Australia"
    #_html: false
    #_points: 1
    #_correct: false
    #_sortString: ""
    #_sortStringHtml: false
    #_mapper: null
  }
  1 => __PHP_Incomplete_Class(WpProQuiz_Model_AnswerTypes) {#1469 ▶}
  2 => __PHP_Incomplete_Class(WpProQuiz_Model_AnswerTypes) {#1480 ▶}
  3 => __PHP_Incomplete_Class(WpProQuiz_Model_AnswerTypes) {#1479 ▶}
]

But here i am not able to fetch the fields as key name showing the function. how to fetch these data using foreach?

Activity icon

Replied to Read Shortcode In Laravel Using Reg Expression

Great it worked. thank you.

Activity icon

Replied to Read Shortcode In Laravel Using Reg Expression

@corvs Thank you so much it is working fine. i should use the loop if it has more than one shortcode right?

Activity icon

Started a new Conversation Read Shortcode In Laravel Using Reg Expression

Hi. I have a content like below,

Hope you enjoy this quiz. If you like it, then please share it. Thank you. [WpProQuiz 2265]

Here i want fetch only [WpProQuiz 2265] if it matches and get the number 2265.

How to do this?

Apr
23
3 weeks ago
Activity icon

Replied to How To Preview .doc File In Laravel

this is the generated iframe code,

<iframe src="https://view.officeapps.live.com/op/embed.aspx?src=http://journal.dsf.uhm.mybluehost.me/admin/manuscriptpreview/Sbo50akS/b8Qb8Abd/doc" width="1366px" height="623px" frameborder="0">This is an embedded <a target='_blank' href='http://office.com'>Microsoft Office</a> document, powered by <a target='_blank' href='http://office.com/webapps'>Office Online</a>.</iframe>

it is not working because I have auth middleware where to access below URL user should log in as admin.

http://journal.dsf.uhm.mybluehost.me/admin/manuscriptpreview/Sbo50akS/b8Qb8Abd/doc

any suggestion?

Activity icon

Replied to How To Preview .doc File In Laravel

thank you i tried to hard refresh the page and it is working fine when I removed auth checker middleware. but now I have enabled it again. it is still working fine. this problem is because of auth middleware?

i am trying this in admin dashboard with auth middleware.

i think this is the security issue because I tried to run this URL directly,

http://journal.dsf.uhm.mybluehost.me/admin/manuscript-preview/Sbo50akS/b8Qb8Abd/doc

it is redirecting to login page which is correct.

but when I tried to run below URL,

https://view.officeapps.live.com/op/embed.aspx?src=http://journal.dsf.uhm.mybluehost.me/admin/manuscript-preview/Sbo50akS/b8Qb8Abd/doc

it is working fine. if the user adds other user files by tweaking the URL It is still working.

Activity icon

Replied to How To Preview .doc File In Laravel

http://journal.dsf.uhm.mybluehost.me/admin/manuscript-preview/Sbo50akS/b8Qb8Abd/doc

i have made this URL public

you can check this. as it is downloading directly. my controller code is,

$docContent = Storage::get($subpath);
      // for pdf, it will be 'application/pdf'
    $type       = Storage::mimeType($subpath);

return Response::make($docContent, 200, [
        'Content-Type'        => $type,
        'Content-Disposition' => 'inline; filename="filename.doc"',
      ]);

iframe code is,

<?php $fullurl = url('admin/manuscript-preview/'.$uuid->uuid.'/'.$manuscript->file_submit_id.'/doc'); ?>

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src={{ $fullurl }}' width='1366px' height='623px' frameborder='0'>This is an embedded <a target='_blank' href='http://office.com'>Microsoft Office</a> document, powered by <a target='_blank' href='http://office.com/webapps'>Office Online</a>.</iframe>

Activity icon

Replied to How To Preview .doc File In Laravel

Ya but i have doc file stored in storage/app/manuscript and I have endpoint to get doc file like below,

$subpath = 'manuscripts/'.$uuid->uuid.'/'.$manuscript->file_name;
    $path = storage_path('app/'.$subpath);

    if (file_exists($path)) {

      $docContent = Storage::get($subpath);
      $type       = Storage::mimeType($subpath);

   
      return Response::make($docContent, 200, [
        'Content-Type'        => $type,
        'Content-Disposition' => 'inline; filename="'.$manuscript->file_name.'"',
      ]);
}
}

if I access this controller endpoint it is downloading directly and I passed in iframe like below,

<?php $fullurl = url('admin/manuscript-preview/'.$uuid->uuid.'/'.$manuscript->file_submit_id.'/doc'); ?>
 <iframe src='https://view.officeapps.live.com/op/embed.aspx?src={{ $fullurl }}' width='1366px' height='623px' frameborder='0'>This is an embedded <a target='_blank' href='http://office.com'>Microsoft Office</a> document, powered by <a target='_blank' href='http://office.com/webapps'>Office Online</a>.</iframe>

But this one not displaying error like below,

File not found
The URL of the original file is not valid or the document is not publicly accessible.
Verify the URL is correct, then contact the document owner.

i tried to add a sample doc file In the public folder and used the below code,

<?php $fullurl = url('Manuscript_1618489590.doc'); ?>
                    <!-- <a href="{{ $fullurl }}"</a> -->
                      <iframe src='https://view.officeapps.live.com/op/embed.aspx?src={{ $fullurl }}' width='1366px' height='623px' frameborder='0'>This is an embedded <a target='_blank' href='http://office.com'>Microsoft Office</a> document, powered by <a target='_blank' href='http://office.com/webapps'>Office Online</a>.</iframe>

this one working fine. i am not getting how to display from the storage folder. please help me with this.

Activity icon

Replied to How To Preview .doc File In Laravel

yes i checked they suggested to use google doc to view the local file but here I am using a private server with authentication which is showing login page code. sample code.

<iframe src="https://docs.google.com/gview?url=http://remote.url.tld/path/to/document.doc&embedded=true"></iframe>

also In PHP word i am not able to find code to preview the doc file.

Activity icon

Replied to Laravel File Not Found At Path: But File Exists.

embed is not but a preview of the doc file. I just want to preview my docs file.

Activity icon

Started a new Conversation How To Preview .doc File In Laravel

i am not able to find how to preview or embed .doc or .docx file in laravel

i have controller code like below,

$subpath = 'manuscripts/'.$uuid->uuid.'/'.$manuscript->file_name;
    $path = storage_path('app/'.$subpath);

    if (file_exists($path)) {

      $pdfContent = Storage::get($subpath);
      // for pdf, it will be 'application/pdf'
      $type       = Storage::mimeType($subpath);

   
      return Response::make($pdfContent, 200, [
        'Content-Type'        => $type,
        'Content-Disposition' => 'inline',
      ]);

same code working fine for pdf file. but I want to preview doc file.

Activity icon

Replied to Laravel File Not Found At Path: But File Exists.

@laracoft thank you. do you know how to embed doc file? i have controller code like below now.

it is working for pdf.

$subpath = 'manuscripts/'.$uuid->uuid.'/'.$manuscript->file_name;
    $path = storage_path('app/'.$subpath);

    if (file_exists($path)) {

      $pdfContent = Storage::get($subpath);
      // for pdf, it will be 'application/pdf'
      $type       = Storage::mimeType($subpath);
      return Response::make($pdfContent, 200, [
        'Content-Type'        => $type,
        'Content-Disposition' => 'inline',
      ]);

    }

    abort(404);
Activity icon

Replied to Laravel File Not Found At Path: But File Exists.

@laracoft Thank you it worked. what was the issue?

Activity icon

Started a new Conversation Laravel File Not Found At Path: But File Exists.

i have a code like below,

public function previewManuscript(ArticleSubmission $uuid, ArticleSubmissionManuscript $manuscript)
    {
      $path = storage_path('app/manuscripts/'.$uuid->uuid.'/'.$manuscript->file_name);

      if (file_exists($path)) {
        // Overwrite the annoying header
        $headers = array(
          // 'Content-Disposition' => 'inline',
          'Content-Type: application/pdf',
        );

        // for pdf, it will be 'application/pdf'
        return $type       = Storage::mimeType($path);
        $fileName   = Storage::name($path);

        // return Storage::download($path, $fig->figure_name, $headers);
          return response()->download($path);

      }

      abort(404);
    }

in above code file_exists function returns true and file exists in the same path. but if use Storage::download or Storage::mimeType then it is giving below error,

File not found at path:

Any solution for this?

Apr
15
1 month ago
Activity icon

Started a new Conversation How To Fetch All Shotcodes Present In Wordpress Post

i am using laravel corcel to fetch all the posts and it is working fine.

I have a quiz inside the post as well and I am using wp pro quiz plugin for quiz now I have studied the db structure of wp pro quiz and now I want to fetch the shortcodes which are present in the post using that I will get a quiz id and using quiz id i will fetch the question.

Example:

if post content is,

<p>Instruction goes here</p>

[WpProQuiz 22840]

Now I want to fetch the number after [WpProQuiz and store it in the array. here 22840 is the quiz id.

each post may have more than one shortcode like below,

<p>Instruction goes here</p>

[WpProQuiz 22840]
[WpProQuiz 22841]

Now my result would be like below,

[22840,22841]

Any idea on how to do this?

i will use this array and fetch the questions and write own query in laravel.

Apr
13
1 month ago
Activity icon

Replied to Laravel Corcel Get Posts By Category

Thank you. I have laravel debugger enabled. How to attach the screenshot here?

Apr
12
1 month ago
Activity icon

Replied to How To Edit Laravel/corcel Package Model Code

i have added but still it is not downloading forked repository it asked for ouath github token and I have generated and added too, my composer.json file.

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "repositories": [{
        "type": "vcs",
        "url": "https://github.com/corcel/corcel"
    }],
    "require": {
        "php": "^7.3|^8.0",
        "fideloper/proxy": "^4.4",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.0.1",
        "jgrossi/corcel": "^5.0",
        "laravel/framework": "^8.12",
        "laravel/passport": "^10.1",
        "laravel/tinker": "^2.5",
        "laravel/ui": "^3.2"
    },
    "require-dev": {
        "barryvdh/laravel-debugbar": "^3.5",
        "facade/ignition": "^2.5",
        "fakerphp/faker": "^1.9.1",
        "laravel/sail": "^1.0.1",
        "mockery/mockery": "^1.4.2",
        "nunomaduro/collision": "^5.0",
        "phpunit/phpunit": "^9.3.3"
    },
    "autoload": {
        "psr-4": {
            "App\": "app/",
            "Database\Factories\": "database/factories/",
            "Database\Seeders\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

i tried to delete the vendor folder and ran the below command

composer install still no use.

Activity icon

Replied to How To Edit Laravel/corcel Package Model Code

Thank you. i will check this.

Activity icon

Started a new Conversation How To Edit Laravel/corcel Package Model Code

i am trying to remove meta info from post response and I am using laravel/corcel package to fetch posts from WordPress DB. and I got to know about the below link,

https://github.com/corcel/corcel/pull/544.

Commit Link

i have edited as they mentioned to make it optional.

And tried to composer update but it is showing like below,

Discard changes [y,n,v,d,s,?]? ?
    y - discard changes and apply the update
    n - abort the update and let you manually clean things up
    v - view modified files
    d - view local modifications (diff)
    s - stash changes and try to reapply them after the update
    ? - print help

I am not able to change the corcel code. how to change this? or any other way to extend this?

Activity icon

Replied to Laravel Corcel Get Posts By Category

@snapey Sorry for many replies, now i have working code like below,

$categories = ['current-affairs-2','current-events-2','editorials'];
        
       $related = new Collection();

                foreach($categories as $key =>$cat)
                {
                    

                        $categorydetail = Taxonomy::slug($cat)->first();
                        
                        $catposts =  $categorydetail->posts()
                                            ->where('post_status', 'publish')
                                            ->whereYear('post_date','2020')
                                            ->whereMonth('post_date', '01')
                                            ->newest()
                                            ->get();

                        $related = $related->merge($catposts);
                }

$unique = $related->unique('ID');
        
        $final = $unique->sortByDesc('post_date')->paginate(10);
        $totalcount = $unique->count();


Here I have to use unique because in my case individual posts will have multiple categories. For example, i have a landing page with the name "current affairs" and I want to display all posts with categories like below

$categories = ['current-affairs-2','current-events-2','editorials'];

we have used more than one categories for some posts like below

Post 1 will have category ['current-affairs-2','current-events-2'];

In this case, after merge duplicates will be displayed so I have used unique() to filter out duplicates on this.

right now I am getting the correct result. but if possible can we optimize this ? can you please check and let me know is this right way to do ?

Activity icon

Replied to Laravel Corcel Get Posts By Category

@snapey now i making this dynamic and my categories will be In array like below,

$categories = ['cat1','cat2','cat3'];
$merged_collection = new Collection();

for($i=0;$i<count($categories); $i++)
{
	$categorydetail = Taxonomy::slug($categories[$i])->first();

	$catposts =  $categorydetail->posts()
                                    ->where('post_status', 'publish')
                                    ->whereYear('post_date','2019')
                                    ->whereMonth('post_date', '10')
                                    ->newest()
                                    ->get();
 $merged_collection->merge($catposts);
}

Here I want to merge all data into one collection so that I will extend like below for single

$mergedcollection->sortByDesc('post_date')->paginate(10);

I tried like above but i am getting an empty response. can you please let me know how to merge using for/foreach? because instead of the hard coding category i will put that in an array by reading the DB.

Activity icon

Replied to Laravel Corcel Get Posts By Category

Thank you for the reply.

it is working and response has pagination data like below,

 "next_page_url": "https://www.example.com/dashboard?page=2",
  "path": "https://www.example.com/dashboard",
  "per_page": 30,
  "prev_page_url": null,
  "to": 30,
  "total": 55

I have used merge on collections.

I tried to display in a table with pagination and it is working and I have used like below,


{{ $data->links() }}

Activity icon

Started a new Conversation How To Display All Categories From Response In Json Data

Hi, i have a response like below,

{

"post_title" :"sdfsf",
"terms": {
        "tag": {
          "current-affairs": "current affairs",
          "pib": "PIB"
        },
        "category": {
          "current-affairs-2": "CURRENT AFFAIRS",
		 "editorials" : "editorials"
        }
  },

}

Now i have a table like below,

<table class="table">
                        <thead>
                          <tr>
                            <th scope="col">#</th>
                            <th scope="col">Title</th>
                            <th scope="col">Category</th>
                          </tr>
                        </thead>
                        <tbody>
                        <?php $i = ($alldata->currentpage()-1)* $alldata->perpage() + 1;?>
                        @foreach($alldata as $fin)
                          <tr>
                            <th scope="row">{{ $i++ }}</th>
                            <td>{{ $fin->post_title }}</td>
                            <td>
                              //here i should display all the categories that are present in terms->categories
                            </td>
                          </tr>
                         @endforeach
                        </tbody>
                      </table>
                        	

SO now I want to fetch terms key and inside terms key, i have tags and categories and i want to display all categories. how to display in blade view. should I use foreach for this. I used foreach but I am getting array to string conversion error. can anyone please check this.